• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
iPhone Development: Multiple Views
 

iPhone Development: Multiple Views

on

  • 13,336 views

 

Statistics

Views

Total Views
13,336
Views on SlideShare
13,241
Embed Views
95

Actions

Likes
3
Downloads
104
Comments
0

3 Embeds 95

http://www.slideshare.net 92
http://php.tpu.fi 2
http://a-ot043.ning.com 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    iPhone Development: Multiple Views iPhone Development: Multiple Views Presentation Transcript

    • iPhone  Development:     Mul1ple  Views   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
    • 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     –  UIBuJon  
    • UIWindow  and  UIView   @interface MultiViewExampleAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; } ... [window addSubview: someView];
    • UIView   •  UIView  is  a  base  class  for  or  the  controls   –  UIView   •  UIControl   –  UIBuJon   •  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  
    • U1lity  Applica1on   •  Primarily  one  view   •  Second  view  for  seLngs   •  Example:  Stock  -­‐   applica1on  
    • Tab  Bar  Applica1on   •  Mul1view  app  that   displays  a  row  of   buJons  at  the  boJom   of  the  screen.   •  Tapping  one  of  the   buJons  causes  new   view  to  be  ac1ve.   •  Example:  Phone-­‐app  
    • Naviga1on-­‐Based  Applica1on   •  Hierarchical  Informa1on   to  the  user   •  Example:  Mail-­‐app  
    • Controlling  Different  Content  Views   •  To  control  different  content  views,  you  must   have  some  kind  of  view  controller   –  UIViewController  (U/lity  app)   –  UITabBarController  (Tab  Bar  app)   –  UINaviga1onController  (Naviga1on  app)  
    • Root  Controller   •  Root  Controller  is  responsible  for  switching   the  views   •  Root  Controller  usually  is   –  UITabBarController –  UINavigationController –  Subclass  of  UIViewController •  Root  Controller  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  
    • Content  View   •  Content  View  holds  controls  (widgets)   •  Content  View  consists  of   1.  View  Controller  (!)   2.  The  Nib  file   3.  Op1onally  subclass  of  UIView  (if  you  need  to   change  the  view  in  code)  
    • 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   UIViewController  /   Interface  Builder   UITabController  /   UIViewController   UINaviga1onController   (.xib)   Content  View   View  Controller   UIView   UIBuJon   Root  Controller   View  Controller   UIView   UIBuJon   View  Controller   UIView   UIBuJon  
    • Once  again:  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