我做它同時支持橫向模式和肖像模式的一個項目,但現在我打有我project.I沒有orentation設置如何在iPhone中設置設備方向?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
//return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
return YES;
}
,但沒有用,當我按命令+右 - 箭頭爲向右旋轉它旋轉到左邊,但視圖和控制器沒有改變到orentation.Then一些谷歌上搜索後,我得到這個代碼
if (self.interfaceOrientation == UIInterfaceOrientationPortrait) {
// do stuff
}
但問題是我不知道如何寫代碼/ /做東西。請幫助我做到這一點。 在此先感謝。 編輯: 我把這個代碼,它是工作,但whenthe模擬器再次變爲縱向它不會是在默認mode.my代碼
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight))
{
NSLog(@"Csantos shouldAutorotateToInterfaceOrientation: left or right");
//
table.transform = CGAffineTransformIdentity;
table.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
table.bounds = CGRectMake(0.0, 0.0, 320, 402);//[self.view setFrame:CGRectMake(0.0, 0.0, 768, 90)];
}
else
{
table.transform = CGAffineTransformIdentity;
table.transform = CGAffineTransformMakeRotation(degreesToRadian(360));
table.bounds = CGRectMake(0.0, 51, 320, 402);
}
return YES;
}*/
可能的重複:http://stackoverflow.com/questions/181780/is-there-a-documented-way-to-set-the-iphone-orientation – Dair