0

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.

JiteshW
  • 2,195
  • 4
  • 32
  • 61
  • Do you wish to Port your iPhone application to iPad check this http://www.raywenderlich.com/1111/how-to-port-an-iphone-application-to-the-ipad. If this is not what you want then please elaborate your problem as its unclear as to what and where do you face the problem – Rahul Sharma Feb 29 '12 at 04:49
  • have a look at this http://stackoverflow.com/questions/5415936/how-to-know-is-it-iphone-or-ipad – Anil Kothari Feb 29 '12 at 07:55

1 Answers1

1

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;
Clafou
  • 15,250
  • 7
  • 58
  • 89
Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • UIUserInterfaceIdiom only evaluates the UI, not the device. So if the OP do not want to configure the app to target the iPad (that is what I understood, he said he does not want to create a universal app), UIUserInterfaceIdiom will always return the iPhone one because is loading the iPhone Simulator within the iPad. Not sure about the behaviour about UIDevice. Maybe he could check if the device is able to manage telephony. – Yorxxx Feb 29 '12 at 08:03
  • Then UIDevice will surely work for you it fetched actual device info even if its simulator it will give simulator also. – Mrunal Feb 29 '12 at 10:09