Iphone 5 4 inch

Possible duplicate:
How to detect iPhone 5 (widescreen devices)?

I am creating an application using Xcode. I noticed that with xcode 4.5, your storyboards can adapt to the screen size of iphone 5. If I create two separate storyboards with different screen sizes, but link the controllers to the same .h file, how can I tell the program that the scan panel loads in depending on the device?

for example: for ipad, when I start, it automatically selects the storyboard

+6
ios xcode
Sep 20 '12 at 16:33
source share
2 answers

The currently marked answer did not work for me, so I created the method below to check if the current device has a 4-inch display.

- (BOOL)hasFourInchDisplay { return ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0); } 

Since this is a known height for the 4-inch display on the iPhone, this is a good indicator.

+49
Sep 21 '12 at 5:26
source share

Add this code to your source code:

 if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){ if([UIScreen mainScreen].bounds.size.height == 568.0)){ //move to your iphone5 storyboard [UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)]; } else{ //move to your iphone4s storyboard [UIStoryboard storyboardWithName:(NSString *) bundle (NSBundle *)]; } } 

.h (header file) contains initialization. After placing the brackets {} and inside the brackets, initialize your data structures such as IBOutlet, int, string. Out of place your methods like IBAction or void .

+6
Sep 20 '12 at 17:55
source share



All Articles