简体   繁体   中英

Autoresize UIView in iPhone5

I've developed an app for iPhone4 and it works perfectly. But when I open it in iPhone 5, some views have a weird behavior. 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. 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. Go to 'Identity Inspector' and uncheck the 'Use Autolayout'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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