簡體   English   中英

在 iPhone5 中自動調整 UIView

[英]Autoresize UIView in iPhone5

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

提前致謝。

打開您的 xib 文件。 轉到“身份檢查器”並取消選中“使用自動布局”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM