Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Cliff McCollum
                                 cliffmcc@gmail.com
                                www.leadingsoftware.ca
...
Universal
Application?
Intended Audience
      1. You understand Objective-C
      2. You have created working iOS Apps before
      3. You are f...
Basic Steps
1. Configure Project Settings
2. Create Your Classes
3. Test
4. Configure Icons
5. Submit
Key Project Settings

                          Always use latest SDK...
                           ...but target oldest O...
Key Project Settings



             Weak-link new libraries.
Initial XIB file



              Shared or separate App Delegate?
                        It’s up to you.
Coding Tools
CHECK CLASS SUPPORT

Class
notificationClass
=
NSClassFromString(@"UILocalNotification");

if
(notificationCl...
Coding Tools
CHECK FOR RETINA DISPLAY

if
([[UIScreen
mainScreen]
respondsToSelector:@selector(scale)]
&&





[[UIScreen
...
Common Patterns
1. Common controller, different bundles.
   if
(UI_USER_INTERFACE_IDIOM()
==
UIUserInterfaceIdiomPad)
{
   


self.infoVie...
2. Common controller, unique presentation.
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
   // On the iPad, ...
2. Common controller, unique presentation.
2. Common controller, unique presentation.


-(void)notesViewCleanup {
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfa...
3. Common Navigation controller,
-(void)display {

                     unique presentation.
    [self prepareDisplay];

 ...
3. Common Navigation controller,
      unique presentation.
3. Common Navigation controller,
              unique presentation.

-(void)cleanupDisplay {

 if (self.usingPopover) {
  ...
4. UIWebView for unique presentation
@media only screen and (min-device-width: 768px) and (max-device-width: 1024px) {
  /...
4. UIWebView for unique presentation

<img src="heart.png" class="LGautosize"/>
5. Unique Subclasses
•Use Subclasses instead of conditionals
•Common behavior in parent class
•Use XIB to create proper su...
Icon Settings




      Application .plist file
REFERENCES
Apple WWDC 2010 Session Videos: http://developer.apple.com/videos/wwdc/2010/
                                Se...
CREDITS


           Opening image: Icon Factory

Sample Application: Teamwork, by Calliope Learning




                 ...
Questions
Upcoming SlideShare
Loading in …5
×

Creating a Universal iOS Application

31,423 views

Published on

This slideshow introduces some basic suggestions and design patterns for creating a Universal application (iPhone and iPad) under iOS.

Presented originally on September 29, 2010 at the Vancouver Island iOS Developers' Group.

Published in: Technology

Creating a Universal iOS Application

  1. 1. Cliff McCollum cliffmcc@gmail.com www.leadingsoftware.ca Universal iOS Applications Some simple patterns and suggestions
  2. 2. Universal Application?
  3. 3. Intended Audience 1. You understand Objective-C 2. You have created working iOS Apps before 3. You are familiar with the XCode environment 4. You have used Interface Builder If this does not describe you, not to worry. As long as you have a good understand of C++, Java, or another related language you should be able to understand the examples.
  4. 4. Basic Steps 1. Configure Project Settings 2. Create Your Classes 3. Test 4. Configure Icons 5. Submit
  5. 5. Key Project Settings Always use latest SDK... ...but target oldest OS Project settings Application .plist file
  6. 6. Key Project Settings Weak-link new libraries.
  7. 7. Initial XIB file Shared or separate App Delegate? It’s up to you.
  8. 8. Coding Tools CHECK CLASS SUPPORT Class
notificationClass
=
NSClassFromString(@"UILocalNotification");
 if
(notificationClass)
{ 

UILocalNotification*
n
=
[[notificationClass
alloc]
init]; } CHECK METHOD SUPPORT if
([UIApplication
 instancesRespondToSelector:@selector(scheduleLocalNotification:)])
{ 

[[UIApplication
sharedApplication]
scheduleLocalNotification:n]; } CHECK DEVICE if
(UI_USER_INTERFACE_IDIOM()
==
UIUserInterfaceIdiomPad)
{ 

//
This
is
a
great
new
Macro
in
recent
SDKs }
  9. 9. Coding Tools CHECK FOR RETINA DISPLAY if
([[UIScreen
mainScreen]
respondsToSelector:@selector(scale)]
&& 




[[UIScreen
mainScreen]
scale]
==
2.0)
{ 




//
do
iPhone
4
stuff }
  10. 10. Common Patterns
  11. 11. 1. Common controller, different bundles. if
(UI_USER_INTERFACE_IDIOM()
==
UIUserInterfaceIdiomPad)
{ 


self.infoViewController
=
[[InfoViewController
alloc] initWithNibName:@"InfoViewController_iPad"
bundle:nil]; } else
{ 


self.infoViewController
=
[[InfoViewController
alloc]
 initWithNibName:@"InfoViewController_iPhone"
bundle:nil]; } iPhone iPad
  12. 12. 2. Common controller, unique presentation. if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { // On the iPad, present the view in a popup controller self.notesViewController = [[NotesViewController alloc] initWithNibName:@"CardNotes_iPad" bundle:nil]; CGSize popoverSize; popoverSize.width = 600; popoverSize.height = 325; self.notesViewController.contentSizeForViewInPopover = popoverSize; self.notesViewPopoverController = [[UIPopoverController alloc] initWithContentViewController:self.notesViewController]; self.notesViewController.modalInPopover = TRUE; CGRect cardTitleRect; cardTitleRect.origin.x = 384; cardTitleRect.origin.y = 180; cardTitleRect.size.width = 1; cardTitleRect.size.height = 1; [self.notesViewPopoverController presentPopoverFromRect:cardTitleRect inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:TRUE]; } else { // iPhone actions self.notesViewController = [[NotesViewController alloc] initWithNibName:@"CardNotes_iPhone" bundle:nil]; [self presentModalViewController:self.notesViewController animated:TRUE]; }
  13. 13. 2. Common controller, unique presentation.
  14. 14. 2. Common controller, unique presentation. -(void)notesViewCleanup { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [self.notesViewPopoverController dismissPopoverAnimated:TRUE]; [self.notesViewPopoverController release]; self.notesViewPopoverController = nil; } else { [self dismissModalViewControllerAnimated:TRUE]; } [self.notesViewController release]; }
  15. 15. 3. Common Navigation controller, -(void)display { unique presentation. [self prepareDisplay]; [self.parentController presentModalViewController:self.navigationController animated:TRUE]; } -(void)displayInPopup { self.usingPopover = TRUE; [self prepareDisplay]; CGSize popoverSize; popoverSize.width = 300; popoverSize.height = 365; self.navigationController.contentSizeForViewInPopover = popoverSize; self.popoverController = [[UIPopoverController alloc] initWithContentViewController:self.navigationController]; CGRect solutionTitleRect; solutionTitleRect.origin.x = 384; solutionTitleRect.origin.y = 420; solutionTitleRect.size.width = 1; solutionTitleRect.size.height = 1; [self.popoverController presentPopoverFromRect:solutionTitleRect inView:self.parentController.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:TRUE]; } -(void)prepareDisplay { self.solutionTableController = [[SolutionSetTableController alloc] initWithNibName:@"SolutionSetTable" bundle:nil]; self.solutionTableController.title = @"Select An Issue"; self.solutionTableController.delegate = self; UINavigationController *newNav = [[UINavigationController alloc] initWithRootViewController:self.solutionTableController]; UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backButtonClicked:)]; newNav.navigationBar.topItem.leftBarButtonItem = backButton; [backButton release]; self.navigationController = newNav; }
  16. 16. 3. Common Navigation controller, unique presentation.
  17. 17. 3. Common Navigation controller, unique presentation. -(void)cleanupDisplay { if (self.usingPopover) { [self.popoverController dismissPopoverAnimated:TRUE]; } else { [self.navigationController dismissModalViewControllerAnimated:TRUE]; } }
  18. 18. 4. UIWebView for unique presentation @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) { /* rules for iPad */ body { font-size: 24px; } img.LGautosize { width: 36px; height: 36px; } img.SMautosize { width: 24px; height: 24px; } } @media only screen and (min-device-width: 320px) and (max-device-width: 480px) { /* iPhone rules here */ body { font-size: 16px; } img.LGautosize { width: 24px; height: 24px; } img.SMautosize { width: 16px; height: 16px; } }
  19. 19. 4. UIWebView for unique presentation <img src="heart.png" class="LGautosize"/>
  20. 20. 5. Unique Subclasses •Use Subclasses instead of conditionals •Common behavior in parent class •Use XIB to create proper subclass •Device specific behavior in subclass
  21. 21. Icon Settings Application .plist file
  22. 22. REFERENCES Apple WWDC 2010 Session Videos: http://developer.apple.com/videos/wwdc/2010/ Sessions 103, 301, 303 Universal Icons: Apple Technical Q&A QA1686
  23. 23. CREDITS Opening image: Icon Factory Sample Application: Teamwork, by Calliope Learning Cliff McCollum cliffmcc@gmail.com www.leadingsoftware.ca
  24. 24. Questions

×