[英]Lock Orientation to Landscape Right in ios7 / Xcode 5
我知道之前曾有人問過這個問題,但我尚未找到解決方案。 在Xcode 5中,我想將我的應用程序鎖定為橫向。 這是我設置項目所采取的步驟。
(1)創建一個單視圖項目
(2)在常規設置標簽下將設備方向設置為橫向
(3)在main.storyboard中將View Controller Orientation設置為Landscape。
(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 x 568
我需要設置什么才能獲得風景(568 x 320)。
謝謝。
即使設備更改為橫向模式,設備/視圖的寬度和高度也將相同,並且始終返回320 x 568。
區別在於用戶可以橫向查看設備。 它不會為您提供預期的寬度和高度變化。 !!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.