Developing an
Universal iOS app
Or converting a existing one into universal...
–Apple Developer Documentation
“A universal app is a single app that is
optimized for iPhone, iPod touch, and iPad
devices.”
Universal app setup
• First you'll need to set project Devices as 'Universal'
–Morpheus
“You take the blue pill -- the story ends, you
wake up in your bed and believe whatever
you want to believe. You take the red pill --
you stay in Wonderland and I show you how
deep the rabbit-hole goes.”
ViewControllers
• Consider defining separate view controller
classes for iPhone and iPad devices.
• If you use a single view controller class for both
platforms, your code must support both iPhone
and iPad screen sizes.
Views
• Consider using separate sets of views for iPhone
and iPad devices. For custom views, this means
defining different versions of your class for each
device.
• If you choose to use the same custom view for
both devices, make sure your drawRect: and
layoutSubviews methods especially work
properly on both devices.
Using Runtime checks
if (UI_USER_INTERFACE_IDIOM() ==
UIUserInterfaceIdiomPad) {
// The device is an iPad running iOS 3.2
or later.
}
else {
// The device is an iPhone or iPod touch.
}
Drawing objects
self.wrapper.frame = CGRectMake(15,
10, self.frame.size.width - 30, 135);
Using different .XIB for the
same ViewController
if ([[UIDevice currentDevice] userInterfaceIdiom]
== UIUserInterfaceIdiomPhone) {
self = [super initWithNibName:nibNameOrNil
bundle:nibBundleOrNil];
} else {
self.view = [[[NSBundle mainBundle]
loadNibNamed:@"DDSigninFormViewController~ipad"
owner:self options:nil] objectAtIndex:0];
}
Live demo/coding
Thank you!
@wevtimoteo
weverton.ct@gmail.com

Developing an Universal iOS app

  • 1.
    Developing an Universal iOSapp Or converting a existing one into universal...
  • 2.
    –Apple Developer Documentation “Auniversal app is a single app that is optimized for iPhone, iPod touch, and iPad devices.”
  • 3.
    Universal app setup •First you'll need to set project Devices as 'Universal'
  • 4.
    –Morpheus “You take theblue pill -- the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill -- you stay in Wonderland and I show you how deep the rabbit-hole goes.”
  • 5.
    ViewControllers • Consider definingseparate view controller classes for iPhone and iPad devices. • If you use a single view controller class for both platforms, your code must support both iPhone and iPad screen sizes.
  • 6.
    Views • Consider usingseparate sets of views for iPhone and iPad devices. For custom views, this means defining different versions of your class for each device. • If you choose to use the same custom view for both devices, make sure your drawRect: and layoutSubviews methods especially work properly on both devices.
  • 7.
    Using Runtime checks if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // The device is an iPad running iOS 3.2 or later. } else { // The device is an iPhone or iPod touch. }
  • 8.
    Drawing objects self.wrapper.frame =CGRectMake(15, 10, self.frame.size.width - 30, 135);
  • 9.
    Using different .XIBfor the same ViewController
  • 10.
    if ([[UIDevice currentDevice]userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; } else { self.view = [[[NSBundle mainBundle] loadNibNamed:@"DDSigninFormViewController~ipad" owner:self options:nil] objectAtIndex:0]; }
  • 11.
  • 12.