1

In my project I have 3 xib files to support different devices. I need to support all devices: iPhone 3, iPhone 4, iPhone 5.

There are:

  • ViewController_iPhone_480.xib
  • ViewController_iPhone_568.xib
  • ViewController_iPad.xib

So, the main problem is that I need to detect which iPhone is being used and load the xib for it.

Very important: I need to check not just the iOS version. And also I don't need to check height or width of screen because it is very strange (for example, if some other device from Apple will have the same height or width in future - how does it help me?)

Have you got a method how to detect an iPhone 5 in code?

Thanks.

2 Answers 2

1
CGSize result = [[UIScreen mainScreen] bounds].size; result.height; // height in pixels result.width; // width in pixels 

Just check the result and make your decision upon that. iPhone 4 has 480 in height, and iPhone 5 has 568 in height.

EDIT: you can check the current device your running on, before you look at height and width.

NSString *deviceType = [UIDevice currentDevice].model; 
Sign up to request clarification or add additional context in comments.

1 Comment

did you read my question very important not just detect width or heigh t, how doest help me for example if iPad mini will have the same size? or iPod touch???
0

You can use the following code to get the platforms:-

[[UIDevice currentDevice] platformType] [[UIDevice currentDevice] platformString] 

The first one gives the platformtype concatenated with the Device type(UIDevice4SiPhone) while second one gives the device type string(iPHone4S).

2 Comments

Excuse me but platformType and platformString symbol are not found in SDK?
Well I am using it , check your ios version ,you can also use model read only property

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.