I solved this problem by doing this.
I have a series of macros (thanks to someone else to answer stackoverflow a few months ago) that I use to determine which device is being used. It:
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) #define IS_IPHONE_5 (IS_IPHONE && [[UIScreen mainScreen]bounds].size.height == 568.0f)
I know that some people are against using macros for a good reason, but I find them useful in some cases. So, to be thorough, macros can be written as methods.
-(BOOL)isIpad {return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? YES : NO;} -(BOOL)isIphone {return UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ? YES : NO;} -(BOOL)isIphone5 {return ([self isIphone] && [[UIScreen mainScreen]bounds].size.height == 568.0f) ? YES : NO;}
I put them in a .h file, which I use specifically for macros called ResourceConstants.h. I import this file into any class in which I should use them.
Once they are defined, go to your -viewDidLoad method in the view controller and set the view angle as follows:
if (IS_IPHONE) self.view.frame = CGRectMake(0, 0, 320, 480);
- EDIT - You may also need to adjust the placement / size of objects / widgets on the screen, since the entire screen is half smaller. You can do this the same way once you create property exits on your view controller to reference any objects on the screen that you need to change. Thus,
self.myobject.frame = CGRectMake(myTopLeftCornerXCoord, myTopLeftCornerYCoord, myWidth, myHeight);
Hope this helps! :)
digitalHound
source share