1

I am developing a comic book using Cocoa Touch in Xcode.I dont know how to get the details of the device whether the device is iphone, ipad or ipod.

I am trying for an universal build.

How to identify the device? Is there a way to change the screen size according to the device?

jonsca
  • 10,218
  • 26
  • 54
  • 62
Raj A.N.T. Gounder
  • 490
  • 1
  • 6
  • 17

6 Answers6

2

You can use this for you first question -

   + (BOOL)isDeviceAniPad {
    #ifdef UI_USER_INTERFACE_IDIOM
        return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
    #else
        return NO;
    #endif
    }

And for you second you don't need to change it your self the iphone/ipad will use use the views sizes that fits its screen. you will have to supply different images sizes or to scale them to the size of the screen.

shannoga
  • 19,649
  • 20
  • 104
  • 169
1

Don't try to check for specific device models, instead check for features of a device.

For screen size lookup UIUserInterfaceIdiom in the docs.

Jonah
  • 17,918
  • 1
  • 43
  • 70
1

NSString *deviceType = [UIDevice currentDevice].model;
NSLog(@"%@",deviceType);

       or
Rams
  • 1,721
  • 12
  • 22
1

if you need to differentiate between all three types of devices:

Determine device (iPhone, iPod Touch) with iPhone SDK

Community
  • 1
  • 1
Russian
  • 1,296
  • 10
  • 15
1

UIDevice class:

NSString *deviceType = [UIDevice currentDevice].model;

if([deviceType isEqualToString:@"iPhone"])
    // it's an iPhone
Chetan Bhalara
  • 10,326
  • 6
  • 32
  • 51
0
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);

now you can compare like
if (strcmp(name, "iPhone1,1")) and others ... "iPhone1,2" ...

Tatvamasi
  • 2,537
  • 19
  • 14