JiteshW
JiteshW

Reputation: 2205

Detect device and accordingly loads UI

Just finished up my iPhone appln, now wants to use same appln for creating an iPad version. What i really want to do is to detect which on which device the app is running and accordingly pick UI at runtime. I get some code regarding which is my current device. Basically main idea behind is that is i don't want to write the server-client communication part again for separate ipad version. Ui is different hence I don't want to create a universal app for this.

My Prob: What settings should I do to make to work the application as described above. Currently when I run using iPhone Simulator, It says tht my current device is iPhone. But, when I changed my device to iPad Simulator and than run it back again, it convert that int iphone simulator.

Thanks.

Upvotes: 0

Views: 214

Answers (1)

Mrunal
Mrunal

Reputation: 14128

you can check with this line:

NSString *model = [[NSString alloc]initWithString:[[UIDevice currentDevice] model]];

model value would be either iPhone or iPad

or you can go with [[UIDevice currentDevice] userInterfaceIdiom] and compare the values with

typedef enum {
   UIUserInterfaceIdiomPhone,
   UIUserInterfaceIdiomPad,
} UIUserInterfaceIdiom;

Upvotes: 1

Related Questions