我知道這個問題以前已經問過,但是Im還沒有找到解決方案。在Xcode 5中,我想將我的應用程序鎖定在右側。以下是我爲建立項目所採取的步驟。在ios7/Xcode 5中鎖定風景的方向
(1)創建一個單一的視圖項目
(2)一般設置選項卡下設置設備方向爲橫向右
(3)視圖控制器方向設定爲橫向main.storyboard
(4)下面的代碼添加到ViewController.m
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
return interfaceOrientation == UIInterfaceOrientationLandscapeRight;
}
-(NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
(5)下面的代碼添加到的ViewController viewDidLoad中
NSLog(@"frame %f %f", self.view.frame.size.width, self.view.frame.size.height);
我每次運行應用程序時我的看法是320×568
什麼我需要設置以獲得橫向視圖(568×320)。
謝謝。
- (BOOL)shouldAutorotate {return YES;}也沒有效果。 – user2872885