Hitesh
Hitesh

Reputation: 61

How can I create xibs for both iPhone 4 and iPhone 5 using Xcode 4.5

I have set deployment target as iOS 4.3 and creating viewcontroller with xib. But XCode 4.5 is creating xib for iPhone 5 (4 inch) only. How can I create a seperate xib for iPhone 4?

Upvotes: 1

Views: 7636

Answers (3)

chathuram
chathuram

Reputation: 636

I was also looking for a solution for the same issue. I have a set of views those who have image views inside them and the existing images look very bad in the iPhone 5. Unfortunately, we need to support all 4.3+ iOS versions and I have no other option but to scale the image view as well as use separate images for two different iPhones. This is what I used to do,

    float height = 480.0f;
    NSString *imageName = @"image640x480";
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        CGSize result = [[UIScreen mainScreen] bounds].size;
        height = result.height;
        imageName = @"image640x568";
    }
    // Set the height of your image view to the height calculated above and use the imageName variable to load the correct image

Upvotes: -1

Mansi Panchal
Mansi Panchal

Reputation: 2357

In your xib , Select the controller and in the property window set the size you want to keep of your view.

Upvotes: 1

Fahri Azimov
Fahri Azimov

Reputation: 11770

In 'Simulated Metrics' section of view's attributes inspector, you can choose between 3,5" or 4" sizes. Choose 3,5", and make your views and subviews resizable, iOS will automatically scale your view to fit iPhone 5's screen.

Upvotes: 11

Related Questions