Same xib for iPhone4 and iPhone5 possible?
Asked Answered
G

8

16

Is there any way I can design my classes for both iPhone4 and iPhone5 using the same xib?

Gooch answered 3/10, 2012 at 5:48 Comment(3)
The link gives description : #7755351Gooch
The link suggested by you shows hoe to set Autoresizing masks "programmatically', it can be done in either of the two ways, not the solution for your issueKila
this link help you and solve your problem #13275644Agitator
E
17

Yes, you can use the same XIB to design for iPhone 4 and iPhone 5 by using Auto-Layout.

Build an app using iOS 6 as the Base SDK and use the Auto Layout feature to make screens that can scale for all type of screens. You'll need Xcode 4.5 to do this.

Get started with Auto Layout here:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2

Efflorescence answered 5/10, 2012 at 11:11 Comment(2)
to expand on using iOS 6 as base sdk this effectively limits your app to iOS 6 will crash on iOS < 6.0 with the error could not instantiate class named nslayoutconstraint.Shanleigh
you can limit the deployment target at iOS 6 so that you can the app will not be deployable for older devices, thereby avoiding chances of crashes.Efflorescence
A
8

Well short answer to you question is YES;

Long is :- If you user XCode 4.5 and build app that is universal the NIB files and Classes would work perfectly for Iphone 4 and Iphone 5; Understand for you it important to know the version of SDK of these mobiles not the mobile version them self.

Another thing is that iphone 5 size is little bigger then iphone 4 so you need to design accordingly.. please read my answer at Iphone 5 screen resolution issue for better understanding.

Also look at the How to develop or migrate apps for iPhone 5 screen resolution? answer for more clarification on universal app desing.

Araucanian answered 3/10, 2012 at 6:12 Comment(0)
D
8

Add a image named [email protected]. That will identify your app as one that supports iPhone 5 metrics. And also you need to do auto sizing of your views properly.

enter image description here

Depot answered 30/1, 2013 at 18:30 Comment(0)
C
5

yes it is possible,enter image description here

just remove the side angle and make object free by enabling inner arrow. so it will automatically resize according to screen.

  • but remember one thing that this will only work when you provide all default or any other splash screen.

enter image description here enter image description here

Crimple answered 17/6, 2013 at 10:21 Comment(0)
I
0

Use AutoAutoresizing so that u can make app compatible with both iOS 5 and iOS 6. This is easy if your layout is having minimum dependancies. And this is possible for fixing issues with components like UIToolBar. Buttons in iPhone 5.

Impudence answered 28/11, 2012 at 7:8 Comment(0)
U
0

If you want to make some small changes(e.g images position and sizes, scroll view content insets..), you can use codes to differentiate between iPhone 5 and iPhone 4/4s, and implement your codes inside the if/else statement.

Use this:

https://mcmap.net/q/99634/-how-to-detect-iphone-5-widescreen-devices

to detect the iPhone type.

Unit answered 18/4, 2013 at 8:9 Comment(0)
S
0

Please define below line and check condition based on device.

#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )

if (IS_IPHONE_5) {

        btnBookmark.frame=CGRectMake(0, 460, 100, 70);
        btnBookmark.frame=CGRectMake(150, 460, 100, 70);


    }else{
        btnBookmark.frame=CGRectMake(0, 360, 100, 70);
        btnBookmark.frame=CGRectMake(150, 360, 100, 70);


    }
Sherlynsherm answered 20/11, 2013 at 9:39 Comment(0)
A
0

You can use auto layout feature provided by apple. Please refer to apple document for this:- https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html

Alcaraz answered 3/4, 2015 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.