在iPad上的iPhone模式下,应用程序在横向上显示

时间:2013-03-22 15:59:12

标签: iphone ios objective-c ipad screen-orientation

当我的应用程序在iPhone上启动时,它会以纵向显示,应该如此。当它以iPhone模式在iPad上启动时,如果以这种方式旋转,它将以横向显示。这是我的代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(BOOL)shouldAutorotate {
    return NO;
}

3 个答案:

答案 0 :(得分:0)

对于iOS 6,请尝试:

- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}

答案 1 :(得分:0)

在项目info.plist文件中,从支持的方向列表中删除横向标记。

答案 2 :(得分:0)

在Xcode中选择一个目标然后在摘要选项卡下确保您只选择了UIpotrait方向并且所有这些方向都未被选中,然后选择信息选项卡并看到在“支持的界面方向”行下它应该只有UIpotrait方向。现在打开您的委托文件,对于ios5,此方法可以正常工作

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait); }

但iOS6不推荐使用此方法来覆盖iOS6

- (BOOL)shouldAutorotate {

return YES;

}

- (NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskPortrait;

} - (NSUInteger)应用程序:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

return UIInterfaceOrientationMaskPortrait;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

return UIInterfaceOrientationPortrait;

}