首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIInterfaceOrientation问题

UIInterfaceOrientation问题
EN

Stack Overflow用户
提问于 2010-10-25 10:01:14
回答 2查看 241关注 0票数 0

UIViewController A、B。

A实现横屏,A转到B。怎么做?取消B的水平屏幕。

B代码:

代码语言:javascript
复制
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

// Return YES for supported orientations
return NO;
}

是不好的!为什么??请帮帮我!谢谢!

EN

回答 2

Stack Overflow用户

发布于 2010-10-25 10:34:10

如果B与A在选项卡栏上,这将不起作用。您需要以模态方式显示B或将其推送到导航控制器上-您还需要在B中至少返回一个方向的YES。

标签栏控制器只支持其所有视图所支持的方向。

票数 0
EN

Stack Overflow用户

发布于 2012-05-10 06:37:17

我刚刚在我的iOS 5.1下的应用程序中修复了这个问题。这是一个古老的问题,但我将把这个问题留给后人,因为我还没有看到其他人在没有应用大量CGAffineTransform代码的情况下解决这个问题,也没有解决真正的问题,那就是UIInterfaceOrientation和UIDeviceOrientation不同步。

在我的例子中,当我从一个只有肖像的ViewController进入一个纵向和横向的ViewController时,我只需要调整方向,而设备在转换之前已经进行了物理旋转。

代码语言:javascript
复制
// The "Interface Orientation" and the "Device Orientation" can become separated in some cases.
// Make sure the view controller only supports the interface orientation for the current device rotation. 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    int deviceRotation = [[UIDevice currentDevice] orientation];
    [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];

    if (deviceRotation == UIDeviceOrientationUnknown ||
        deviceRotation == UIDeviceOrientationFaceUp  ||
        deviceRotation == UIDeviceOrientationFaceDown)
        return YES;

    if (deviceRotation != interfaceOrientation)
        return NO;
    else
        return YES;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4011433

复制
相关文章

相似问题

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