iphone - 无法在 iPad 上正确旋转翻译后的 UIView

标签 iphone ipad ios uiviewcontroller rotation

我有一个UIViewController,里面有两个UIView,其布局(在Interface Builder中设置)是这样的(洋红色 View 是UIViewController默认 View ):

enter image description here

我将主视图添加到 Root View 中以获得此效果(通过不显示将其框架放在底部的较暗 View ):

enter image description here

现在当设备旋转时,我得到的是这样的:

enter image description here

而我仍然想隐藏较暗的 View 。 这是我用来在它出现时隐藏它的代码(我在 viewDidLoad 方法中使用它):

- (void)hideAll:(float)time{
        CGRect hiddenFrame = CGRectMake(0, 1024, self.view.frame.size.width, self.view.frame.size.height);
        [self.view setFrame:hiddenFrame];
        [self.view setNeedsDisplay];
}

它似乎可以工作,但是当我在旋转时调用它的变体时(在 willRotateToInterfaceOrientation:duration: 中),没有任何反应:

    CGRect hiddenFrame = CGRectMake(0, 748, self.view.frame.size.width, self.view.frame.size.height);
    [self.view setFrame:hiddenFrame];
    [self.view setNeedsDisplay];

我错过了什么?我需要在 Interface Builder 中设置一些其他 View 属性吗?

更新

在我看来,设备旋转后坐标系不会改变(即纵向模式下设置在左上角的原点在横向模式下顺时针旋转后会变成右上角)

最佳答案

检查 IB 中的支柱和 Spring 。也许当您自动旋转时,将您固定在屏幕顶部的支柱会将您的框架移回顶部。

尝试将代码添加到 didRotateToInterfaceOrientation 方法中,以便它可以在旋转发生后运行。

关于iphone - 无法在 iPad 上正确旋转翻译后的 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4913168/

相关文章:

iphone - NSPredicate 过滤空格和字母数字

ios - iPhone registerForRemoteNotificationTypes 不会产生错误但不会触发提供设备 token 的委托(delegate)

iphone - 实现 NSURLRequest、NSURLConnection 和 NSURLRequestReturnCacheDataElseLoad 策略

iPhone 远程 IO 问题

iphone - Iphone 中的股票图表?

c# - 没有 StackTrace 或日志的 Monotouch 应用程序崩溃(从未调用析构函数)

javascript - iPad、JavaScript 字符代码和 shiftKey

ios - 使用 QuartzCore 为 UITextView 创建阴影

iOS游戏陀螺仪——用户需要静止时如何检测作弊

ios - 大写字符在Iphone中转换为区分大小写