1

我为 iPhone4 开发了一个应用程序,它运行良好。但是当我在 iPhone 5 中打开它时,一些视图有一个奇怪的行为。例如,某些空间更大或某些元素更大,我不希望这样。其中一个失败是像消息应用程序这样的屏幕,用于书写的文本字段在 iPhone 4 中可以完美运行,但在 iPhone 5 中它要大得多。我试图用这个来调整它:

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];
}

提前致谢。

4

1 回答 1

1

打开您的 xib 文件。转到“身份检查器”并取消选中“使用自动布局”。

于 2012-11-24T15:58:20.963 回答