Skip to content

Instantly share code, notes, and snippets.

@timbergus
Created January 31, 2013 22:51
Show Gist options
  • Select an option

  • Save timbergus/4687430 to your computer and use it in GitHub Desktop.

Select an option

Save timbergus/4687430 to your computer and use it in GitHub Desktop.
This code initialize the different sizes of the iPhone/iPad screens to do something depending on which device we are using.
UIDevice *device = [[UIDevice alloc] init];
if ([device.model isEqualToString:@"iPhone"] || [device.model isEqualToString:@"iPhone Simulator"]) {
if ([[UIScreen mainScreen] bounds].size.height == 480) {
// Do something with the iPhone
}
if ([[UIScreen mainScreen] bounds].size.height == 568) {
// Do something with the iPhone5
}
}
if ([device.model isEqualToString:@"iPad"] || [device.model isEqualToString:@"iPad Simulator"]) {
// Do something with the iPad
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment