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?
Asked
Active
Viewed 7,628 times
1
-
I don't think you can (or need to) make a separate xib for the other screen size. See Fahri's answer. Making the views resizable should be very easy (especially if you want to use the new constraints feature that is in SDK 6.0) – Cashew Sep 25 '12 at 12:01
-
this link help you and solve your problem http://stackoverflow.com/questions/13275144/how-to-make-xib-compatible-with-both-iphone-5-and-iphone-4-devices/13283851#13283851 – Waseem Shah Feb 26 '13 at 06:54
3 Answers
11
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.

Fahri Azimov
- 11,470
- 2
- 21
- 29
-
With only one xib, it was crashing on below 6.0. I unchecked Use Autolayout and crashing stopped. So if deployment target is iOS 4.3, I cannot use Autolayout? – Hitesh Sep 25 '12 at 12:21
-
3@Hitesh:You can only use Auto Layout (constraints) with the deployment target of iOS 6+ as this is a brand new feature in iOS. – Robotic Cat Sep 25 '12 at 12:29
-
I am wondering ,,, how the resize will done here? in IB or code ? – MohamMad Salah Feb 20 '13 at 12:22
-
1
In your xib , Select the controller and in the property window set the size you want to keep of your view.

Mansi Panchal
- 2,357
- 18
- 27
-1
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

chathuram
- 616
- 2
- 5
- 23