Question

I have an iPad app that I would like to make Universal, however this seems alarmingly difficult. I've changed things around so that I support both builds, but when building, I get lots of errors about using UIPopOvers. Here're my questions:

  • Why does UI_USER_INTERFACE_IDIOM() not compile or register on 3.1.3?
  • Can I conditionally have variables in a class definition based on UI_USER_INTERFACE_IDIOM()?
  • If not, should I make two different view controllers?

Thanks!

Was it helpful?

Solution

Why does UI_USER_INTERFACE_IDIOM() not compile or register on 3.1.3?

The UI_USER_INTERFACE_IDIOM macro is only available starting with 3.2. Same restrictions for the userInterfaceIdiom property of UIDevice. This means that you can only get universal application starting with SDK 3.2.

Can I conditionally have variables in a class definition based on UI_USER_INTERFACE_IDIOM()?

No. The UI_USER_INTERFACE_IDIOM macro is only a runtime shortcut to get the current UI idiom of the device.

If not, should I make two different view controllers?

If you have very different UI between the two devices, it is wiser to use two different view controllers, and to create the right one at runtime (in the application controller for example) by using the UI_USER_INTERFACE_IDIOM macro.

OTHER TIPS

I had pretty good luck with just selecting the target then going to Project->Upgrade current target for iPad.

My app is pretty simple, consisting mostly of table views and webviews, but it's worth making a backup and trying...

And yes, you have to submit it as a 3.2 app that can target 3.1.*

There are also a lot of other stuff that you have to do: Make sure that it can be viewed at any orientation (got rejected the first time for this). Make sure that you have all the new images created. you have to have 3 or 4 icons, instead of just one like an iPhone app needed. (iPad icon, iPhone icon, small icon for spotlight, etc). And of course iPad sized screenshots for the store.

A really nice way that I use to test if it's an iPad or iPhone is to check if the device can use a split view controller, since for the forseeable future no device with a screen as small as an iPhone will be able to use the split view controller. I just created a function to do this for me:

+(BOOL)isIpad{ return NSClassFromString(@"UISplitViewController") != nil; }

Then anywhere in my app that I want to display something different depending on device, I just do a check for it:

int width = 150;
if([NabAppDelegate isIpad]){
   width = 350;
} else {
   width = 150;
}
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5,10,width,25)];

This is a lot better than checking against OS version like I've seen some suggest.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top