【问题标题】:View frame changed in the iPhone 3.5" simulator from iPhone 4-inch screen xib从 iPhone 4 英寸屏幕 xib 在 iPhone 3.5" 模拟器中更改视图框架
【发布时间】:2013-02-05 09:19:34
【问题描述】:

我将视图控制器 XIB 制作为 4 英寸视网膜屏幕,并在底部放置了一个自定义视图。
我在 iPhone4 3.5" 模拟器上运行该应用程序。
大多数 iPhone 版本都应该支持我的应用程序,所以我在视图控制器的 viewdidload 上设置了视图的框架。我本来打算第一次隐藏视图,结果视图的框架设置为{{-320, 401}, {320, 147}}.
但是在viewwillappear中,我发现view的frame被重置为{{0, 313}, {320, 147}}

我想知道为什么这个框架会自动改变。

感谢您的帮助。

【问题讨论】:

  • 为什么要以这种方式隐藏视图?为什么不使用 view.hidden 属性?
  • 是的,view.hidden 是隐藏视图的更好方法。
  • 我要展示动画。

标签: iphone iphone-5 viewdidload viewwillappear


【解决方案1】:
Try This Code

+(BOOL)isDeviceiPhone5
{
    BOOL iPhone5 = FALSE;

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
        // code for 4-inch screen
        iPhone5 = TRUE;
    }
    else
    {
        iPhone5 = FALSE;
        // code for 3.5-inch screen
    }
    return iPhone5;

}


+(CGRect )getFrameFor_iPhone4_height:(CGRect)frame
{
    frame.size.height = frame.size.height - 87.0;
    return frame;
}
+(CGRect )getFrameFor_iPhone4_yPos:(CGRect)frame
{
    frame.origin.y = frame.origin.y - 87.0;
    return frame;
}

【讨论】:

    猜你喜欢
    • 2014-03-30
    • 2014-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-12-13
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多