从iPhone 4英寸屏幕xib在iPhone 3.5“模拟器中更改了视图框架

时间:2013-02-05 09:19:35

标签: iphone iphone-5 viewdidload viewwillappear

我将一个viewcontroller XIB作为4“视网膜屏幕并在底部放置了一个自定义视图 我在iPhone4 3.5“模拟器上运行应用程序 大多数iPhone版本都应支持我的应用程序,因此我在视图控制器的viewdidload上设置了视图的框架。我将在第一时间隐藏视图,因此视图的框架设置为{{-320, 401}, {320, 147}}.
但是在viewwillappear中,我发现视图的框架已重置为{{0, 313}, {320, 147}}

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

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

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;
}
相关问题