SlideShare a Scribd company logo
iPhone	
  Development:	
  	
  
      Mul1ple	
  Views	
  
            Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  Applied	
  Sciences	
  
Mul1view	
  App:	
  U1lity	
  Applica1on	
  
•  Primarily	
  one	
  view	
  
•  Second	
  view	
  for	
  seAngs	
  
•  Example:	
  Stock	
  -­‐	
  
   applica1on	
  
Mul1view	
  App:	
  Tab	
  Bar	
  Applica1on	
  
•  Mul1view	
  app	
  that	
  
   displays	
  a	
  row	
  of	
  
   buIons	
  at	
  the	
  boIom	
  
   of	
  the	
  screen.	
  
•  Tapping	
  one	
  of	
  the	
  
   buIons	
  causes	
  new	
  
   view	
  to	
  be	
  ac1ve.	
  
•  Example:	
  Phone-­‐app	
  
Mul1view	
  App:	
  	
  
         Naviga1on-­‐Based	
  Applica1on	
  
•  Hierarchical	
  
   Informa1on	
  to	
  the	
  user	
  
•  Example:	
  Mail-­‐app	
  
Terminology	
  of	
  Views	
  
•  BuIons,	
  Labels	
  and	
  other	
  controls	
  are	
  
   subclasses	
  of	
  UIView
•  View	
  generally	
  refers	
  to	
  subclass	
  of	
  UIView	
  
   that	
  has	
  corresponding	
  view	
  controller	
  
•  Views	
  with	
  view	
  controller	
  are	
  called	
  content	
  
   views.	
  
UIWindow?	
  
•  UIWindow:	
  the	
  path	
  to	
  the	
  user	
  
•  If	
  you	
  want	
  something	
  to	
  be	
  visible	
  for	
  the	
  
   user,	
  you	
  must	
  use	
  the	
  UIWindow!	
  
•  UIView	
  objects	
  are	
  arranged	
  in	
  UIWindow	
  in	
  
   hierarchy.	
  
•  Parent	
  object	
  is	
  called	
  superview	
  
    –  UIWindow	
  
        •  UIView 	
  	
  
            – UIBuIon	
  
UIWindow	
  and	
  UIView	
  
@interface MultiViewExampleAppDelegate : NSObject
  <UIApplicationDelegate> {
    UIWindow *window;
}
...
[window addSubview: someView];
UIView	
  
•  UIView	
  is	
  a	
  base	
  class	
  for	
  or	
  the	
  controls	
  
     –  UIView	
  
          •  UIControl	
  
               –  UIBuIon	
  
•  UIView	
  may	
  be	
  also	
  a	
  content	
  view,	
  or	
  canvas.	
  
•  UIView	
  holds	
  several	
  controls:	
  
     –  [someUIView addSubView: someButton];
•  So	
  basically	
  we	
  could	
  have	
  a	
  UIWindow,	
  that	
  has	
  
   one	
  UIView	
  that	
  contains	
  two	
  UIViews	
  which	
  
   contains	
  several	
  controls	
  
Controlling	
  Different	
  Content	
  Views	
  
•  To	
  control	
  different	
  content	
  views,	
  you	
  must	
  
   have	
  some	
  kind	
  of	
  root	
  controller	
  
   –  UIViewController	
  (U2lity	
  app)	
  
   –  UITabBarController	
  (Tab	
  Bar	
  app)	
  
   –  UINaviga1onController	
  (Naviga1on	
  app)	
  
•  RootController	
  is	
  responsible	
  of	
  switching	
  
   views	
  
•  RootController	
  holds	
  content	
  views	
  
Controller	
  and	
  Content	
  View	
  

                               Content	
  View	
  




      Root	
  Controller	
     Content	
  View	
  




                               Content	
  View	
  
Rela1onship	
  




                                       Gray's	
  view	
  




Root's	
  view	
  
Rela1onship	
  




                                       White's	
  view	
  




Root's	
  view	
  
Tab	
  Bar	
  Applica1on	
  




Root's	
  view	
  
Content	
  View	
  
•  Content	
  View	
  holds	
  controls	
  (widgets)	
  
•  Content	
  View	
  consists	
  of	
  
       1.  View	
  Controller	
  (!)	
  
       2.  The	
  Nib	
  file	
  
	
  
	
  
Controller	
  and	
  Content	
  View	
  
                                         Content	
  View	
  
                           View1Controller.h	
  
                           View1Controller.m	
  
                                                        View1.xib	
  




                                         Content	
  View	
  
  Root	
  Controller	
     View2Controller.h	
  
                           View2Controller.m	
  
                                                        View2.xib	
  



                                         Content	
  View	
  
                           View3Controller.h	
  
                           View3Controller.m	
  
                                                        View3.xib	
  
Hierarchy	
  
                                                                          Interface	
  Builder	
  
UIViewController	
                         UIViewController	
                   (.xib)	
  


                     Content	
  View	
  

                                           View	
  Controller	
     UIView	
                UIBuIon	
  




 Root	
  Controller	
                      View	
  Controller	
     UIView	
                UIBuIon	
  




                                           View	
  Controller	
     UIView	
                UIBuIon	
  
Delegate	
  Class	
  
#import <UIKit/UIKit.h>
#import "SwitchViewController.h"

@interface MyAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    SwitchMyViewController *switchmyviewcontroller;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet SwitchMyViewController
   *switchmyviewcontroller;

@end
Delegate	
  Class	
  .m	
  
- (BOOL)application:(UIApplication *)application
   didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    // Override point for customization after application launch.
    [window addSubview: switchmyviewcontroller.view];
    [window makeKeyAndVisible];

    return YES;
}
Root	
  Controller	
  
// Promise we will import these classes later
@class GrayViewController;
@class WhiteViewController;

@interface SwitchMyViewController : UIViewController {
    GrayViewController *grayViewController;
    WhiteViewController *whiteViewController;
}

@property (nonatomic, retain) GrayViewController *grayViewController;
@property (nonatomic, retain) WhiteViewController *whiteViewController;

// This method can change views. You can have for example a button
// that changes the content view
- (IBAction) switchViews:(id) sender;

@end
Content	
  View's	
  Controller	
  
#import <UIKit/UIKit.h>


@interface WhiteViewController: UIViewController {

}

// Possible actions and outlets
-(IBAction) grayButtonPressed:(id) sender;


@end
UIViewController	
  -­‐>	
  View?	
  
•  Each	
  View	
  Controller	
  has	
  a	
  View...	
  
    –  ..where	
  all	
  the	
  controls,	
  widgets,	
  are	
  stored	
  
•  The	
  view	
  is	
  usually	
  implemented	
  in	
  Interface	
  
   builder	
  
•  So	
  you	
  should	
  have	
  
    –  MyView1Controller.h
    –  MyView1Controller.m
    –  MyView1.xib
Crea1ng	
  Controllers	
  
Crea1ng	
  .nib	
  files	
  

More Related Content

PDF
Creating Container View Controllers
PPT
Honest2God
PPTX
Ten Things Every Marine Executive Needs to Know About Facebook and Social Media
PPTX
The 10 Golden Rules Of Maximizing Corporate Growth Online
PPT
Entrepreneur Ship
PPTX
MMShihab's case presentation 2015
PPTX
Osaka
PPT
Ten golden rules of social media slides 01 09 14
Creating Container View Controllers
Honest2God
Ten Things Every Marine Executive Needs to Know About Facebook and Social Media
The 10 Golden Rules Of Maximizing Corporate Growth Online
Entrepreneur Ship
MMShihab's case presentation 2015
Osaka
Ten golden rules of social media slides 01 09 14

Similar to iPhone Development: Multiple Views (20)

PDF
iOS: View Controllers
PPTX
iOS Development (Part 3) - Additional GUI Components
PPTX
Objective c design pattens-architetcure
PDF
Introduction of Xcode
PPTX
Android and IOS UI Development (Android 5.0 and iOS 9.0)
PDF
Session 8 - Xcode 5 and interface builder for iOS 7 application
PPTX
Building your first iOS app using Xamarin
KEY
storyboard時代のInterfaceBuilder
PPTX
Code camp 2011 Getting Started with IOS, Una Daly
PDF
iPhone Programming [7/17] : Behind the Scene
PDF
Intro to UIKit • Made by Many
PDF
아이폰강의(5) pdf
PDF
iPhone SDK dev sharing - the very basics
PDF
Assignment 4 Paparazzi1
PPTX
Head first iOS programming
DOCX
Beginning iOS 7 Development Exploring the iOS SDKby Jack .docx
PDF
I pad uicatalog_lesson02
PDF
View controllerp gforios
PDF
Beginning iOS6 Development CH06 Multiview Applications
iOS: View Controllers
iOS Development (Part 3) - Additional GUI Components
Objective c design pattens-architetcure
Introduction of Xcode
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Session 8 - Xcode 5 and interface builder for iOS 7 application
Building your first iOS app using Xamarin
storyboard時代のInterfaceBuilder
Code camp 2011 Getting Started with IOS, Una Daly
iPhone Programming [7/17] : Behind the Scene
Intro to UIKit • Made by Many
아이폰강의(5) pdf
iPhone SDK dev sharing - the very basics
Assignment 4 Paparazzi1
Head first iOS programming
Beginning iOS 7 Development Exploring the iOS SDKby Jack .docx
I pad uicatalog_lesson02
View controllerp gforios
Beginning iOS6 Development CH06 Multiview Applications
Ad

More from Jussi Pohjolainen (20)

PDF
Moved to Speakerdeck
PDF
Java Web Services
PDF
Box2D and libGDX
PDF
libGDX: Screens, Fonts and Preferences
PDF
libGDX: Tiled Maps
PDF
libGDX: User Input and Frame by Frame Animation
PDF
Intro to Building Android Games using libGDX
PDF
Advanced JavaScript Development
PDF
Introduction to JavaScript
PDF
Introduction to AngularJS
PDF
libGDX: Scene2D
PDF
libGDX: Simple Frame Animation
PDF
libGDX: Simple Frame Animation
PDF
libGDX: User Input
PDF
Implementing a Simple Game using libGDX
PDF
Building Android games using LibGDX
PDF
Android Threading
PDF
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
PDF
Creating Games for Asha - platform
PDF
Intro to Asha UI
Moved to Speakerdeck
Java Web Services
Box2D and libGDX
libGDX: Screens, Fonts and Preferences
libGDX: Tiled Maps
libGDX: User Input and Frame by Frame Animation
Intro to Building Android Games using libGDX
Advanced JavaScript Development
Introduction to JavaScript
Introduction to AngularJS
libGDX: Scene2D
libGDX: Simple Frame Animation
libGDX: Simple Frame Animation
libGDX: User Input
Implementing a Simple Game using libGDX
Building Android games using LibGDX
Android Threading
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Games for Asha - platform
Intro to Asha UI
Ad

Recently uploaded (20)

PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
VCE English Exam - Section C Student Revision Booklet
PPTX
Presentation on HIE in infants and its manifestations
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
master seminar digital applications in india
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
Lesson notes of climatology university.
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Classroom Observation Tools for Teachers
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
VCE English Exam - Section C Student Revision Booklet
Presentation on HIE in infants and its manifestations
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
master seminar digital applications in india
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Lesson notes of climatology university.
Module 4: Burden of Disease Tutorial Slides S2 2025
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Classroom Observation Tools for Teachers
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
GDM (1) (1).pptx small presentation for students
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

iPhone Development: Multiple Views

  • 1. iPhone  Development:     Mul1ple  Views   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 2. Mul1view  App:  U1lity  Applica1on   •  Primarily  one  view   •  Second  view  for  seAngs   •  Example:  Stock  -­‐   applica1on  
  • 3. Mul1view  App:  Tab  Bar  Applica1on   •  Mul1view  app  that   displays  a  row  of   buIons  at  the  boIom   of  the  screen.   •  Tapping  one  of  the   buIons  causes  new   view  to  be  ac1ve.   •  Example:  Phone-­‐app  
  • 4. Mul1view  App:     Naviga1on-­‐Based  Applica1on   •  Hierarchical   Informa1on  to  the  user   •  Example:  Mail-­‐app  
  • 5. Terminology  of  Views   •  BuIons,  Labels  and  other  controls  are   subclasses  of  UIView •  View  generally  refers  to  subclass  of  UIView   that  has  corresponding  view  controller   •  Views  with  view  controller  are  called  content   views.  
  • 6. UIWindow?   •  UIWindow:  the  path  to  the  user   •  If  you  want  something  to  be  visible  for  the   user,  you  must  use  the  UIWindow!   •  UIView  objects  are  arranged  in  UIWindow  in   hierarchy.   •  Parent  object  is  called  superview   –  UIWindow   •  UIView     – UIBuIon  
  • 7. UIWindow  and  UIView   @interface MultiViewExampleAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; } ... [window addSubview: someView];
  • 8. UIView   •  UIView  is  a  base  class  for  or  the  controls   –  UIView   •  UIControl   –  UIBuIon   •  UIView  may  be  also  a  content  view,  or  canvas.   •  UIView  holds  several  controls:   –  [someUIView addSubView: someButton]; •  So  basically  we  could  have  a  UIWindow,  that  has   one  UIView  that  contains  two  UIViews  which   contains  several  controls  
  • 9. Controlling  Different  Content  Views   •  To  control  different  content  views,  you  must   have  some  kind  of  root  controller   –  UIViewController  (U2lity  app)   –  UITabBarController  (Tab  Bar  app)   –  UINaviga1onController  (Naviga1on  app)   •  RootController  is  responsible  of  switching   views   •  RootController  holds  content  views  
  • 10. Controller  and  Content  View   Content  View   Root  Controller   Content  View   Content  View  
  • 11. Rela1onship   Gray's  view   Root's  view  
  • 12. Rela1onship   White's  view   Root's  view  
  • 13. Tab  Bar  Applica1on   Root's  view  
  • 14. Content  View   •  Content  View  holds  controls  (widgets)   •  Content  View  consists  of   1.  View  Controller  (!)   2.  The  Nib  file      
  • 15. Controller  and  Content  View   Content  View   View1Controller.h   View1Controller.m   View1.xib   Content  View   Root  Controller   View2Controller.h   View2Controller.m   View2.xib   Content  View   View3Controller.h   View3Controller.m   View3.xib  
  • 16. Hierarchy   Interface  Builder   UIViewController   UIViewController   (.xib)   Content  View   View  Controller   UIView   UIBuIon   Root  Controller   View  Controller   UIView   UIBuIon   View  Controller   UIView   UIBuIon  
  • 17. Delegate  Class   #import <UIKit/UIKit.h> #import "SwitchViewController.h" @interface MyAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; SwitchMyViewController *switchmyviewcontroller; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet SwitchMyViewController *switchmyviewcontroller; @end
  • 18. Delegate  Class  .m   - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [window addSubview: switchmyviewcontroller.view]; [window makeKeyAndVisible]; return YES; }
  • 19. Root  Controller   // Promise we will import these classes later @class GrayViewController; @class WhiteViewController; @interface SwitchMyViewController : UIViewController { GrayViewController *grayViewController; WhiteViewController *whiteViewController; } @property (nonatomic, retain) GrayViewController *grayViewController; @property (nonatomic, retain) WhiteViewController *whiteViewController; // This method can change views. You can have for example a button // that changes the content view - (IBAction) switchViews:(id) sender; @end
  • 20. Content  View's  Controller   #import <UIKit/UIKit.h> @interface WhiteViewController: UIViewController { } // Possible actions and outlets -(IBAction) grayButtonPressed:(id) sender; @end
  • 21. UIViewController  -­‐>  View?   •  Each  View  Controller  has  a  View...   –  ..where  all  the  controls,  widgets,  are  stored   •  The  view  is  usually  implemented  in  Interface   builder   •  So  you  should  have   –  MyView1Controller.h –  MyView1Controller.m –  MyView1.xib