首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅具有横向模式的iPad应用程序,问题

问仅具有横向模式的iPad应用程序,问题
EN

Stack Overflow用户
提问于 2011-12-02 17:58:40
回答 2查看 225关注 0票数 0
代码语言:javascript
复制
if (interfaceOrientation == UIInterfaceOrientationPortrait) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        NSLog(@"Landscape left detected!");
        return NO;
} else if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        NSLog(@"Landscape right detected!");
        return YES;
}

我正在尝试实现一个只有风景模式的iPad应用程序。我在info.plist中将支持的界面方向设置为横向模式。WHen应用程序启动,视图本身处于横向模式。但是当我在登录后添加了另一个视图,例如Home视图,视图不会旋转为横向视图。这是在肖像模式。在xib文件中,我也将其设置为横向。我已经在登录和主视图控制器中包含了上面的代码。但主视图在登录后不会旋转。

EN

回答 2

Stack Overflow用户

发布于 2011-12-02 18:04:30

在每个视图控制器中执行此操作

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
}
票数 0
EN

Stack Overflow用户

发布于 2011-12-02 18:12:58

首先,你不必为每个方向都写检查。只需在视图控制器的shouldAutorotateToInterfaceOrientation方法中使用以下代码即可实现这一点

代码语言:javascript
复制
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);

第二,你能提供更多关于你是如何实际添加更多视图的细节吗?发现问题会更有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8354561

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档