I have two xibs, one for the iPhone 4 and one for the iPhone 5; 3.5 inch and 4 inch. I simply want to put some code that tells the app which to load. I have this code which is supposed to do the job:
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone))
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
//Load 3.5 inch xib
}
if(result.height == 568)
{
//Load 4 inch xib
}
I put it in the ViewController.M(is that where I put it?) and the build fails saying there is a parse issue expected identifier of "(" Can anyone help me with this simple fix? Thanks!
add below line in your prefix.pch file...this is the simplest way to check screen size, no need to make extra lines of code...
#define IsIphone5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
now whereever you want to check screen size , just make condition like below, and you can do whatever you want....
if(IsIphone5)
{
//your stuff
}
else
{
//your stuff
}
Happy Coding!!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With