iPhone Development

Just another iPhone Blog

Tools helpful in Creating Universal iOS Apps

This post is about Tools [Code Snippets] which I prepared in the process of creating Universal iOS Apps

 

1. Identifying the Device

 

#device DEVICE_IS_IPAD (UIUserInterfaceIdiomiPad == [BBUtilities getUserInterfaceIdiom])

#device DEVICE_IS_IPHONE (UIUserInterfaceIdiomiPhone == [BBUtilities getUserInterfaceIdiom])

 

/*snippet to get user interface idiom*/

static UIUserInterfaceIdiom sDeviceUIIdiom = -1; -(UIUserInterfaceIdiom)getUserInterfaceIdiom

{

 

//We make sure that this method is invoked only once throughout the application lifetime

if( sDeviceUIIdiom == -1)

{

if([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)])

{

sDeviceUIIdiom = [[UIDevice currentDevice] userInterfaceIdiom];

}

}

return sDeviceUIIdiom;

}

 

2. Identifying iPhone 4 Device

 

#define DEVIS_IS_IPHONE4 ([BBUtilities isiPhone4])

 

/*snippet to get whether current device is iPhone 4 or not*/

static UIUserInterfaceIdiom sIsiPhone4 = -1;

 

-(BOOL) isiPhone4

{

//We make sure that this method is invoked only once throughout the application lifetime     i

if( sIsiPhone4 == -1)

{

if([[UIScreen mainScreen] respondsToSelector:@selector(scale)])

{

sIsiPhone4 = [[UIScreen mainScreen] scale] ==2.0 ;

}

else

{

sIsiPhone4=0;

}

}

return sIsiPhone4;

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: