简体   繁体   English

在 iPhone5 中自动调整 UIView

[英]Autoresize UIView in iPhone5

I've developed an app for iPhone4 and it works perfectly.我为 iPhone4 开发了一个应用程序,它运行良好。 But when I open it in iPhone 5, some views have a weird behavior.但是当我在 iPhone 5 中打开它时,一些视图有一个奇怪的行为。 For example, some spaces are bigger or some elements are bigger, and I don't want that.例如,一些空间更大或一些元素更大,我不想要这样。 One of the failures is a screen like the messages app, and the textfield for writing works perfectly in iPhone 4, but in iPhone 5 it is so much bigger.失败之一是像消息应用程序这样的屏幕,用于书写的文本字段在 iPhone 4 中完美运行,但在 iPhone 5 中它要大得多。 I tried to adjust it with this:我试图用这个来调整它:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
    // code for 4-inch screen
    NSLog(@"Iphone 5");
    CGRect frameTable = CGRectMake(0, 0, 320, 454);
    [tableView setFrame:frameTable];

    CGRect frameTextView = CGRectMake(0, 454, 320, 50);
    [textInputView setFrame:frameTextView];
} else {
    // code for 3.5-inch screen
    NSLog(@"Iphone 4");
    CGRect frameTable = CGRectMake(0, 0, 320, 376);
    [tableView setFrame:frameTable];

    CGRect frameTextView = CGRectMake(0, 376, 320, 50);
    [textInputView setFrame:frameTextView];
}

Thanks in advance.提前致谢。

Open your xib file.打开您的 xib 文件。 Go to 'Identity Inspector' and uncheck the 'Use Autolayout'.转到“身份检查器”并取消选中“使用自动布局”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM