Juanjo
Juanjo

Reputation: 969

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.

Upvotes: 1

Views: 769

Answers (1)

Afnan
Afnan

Reputation: 898

Open your xib file. Go to 'Identity Inspector' and uncheck the 'Use Autolayout'.

Upvotes: 1

Related Questions