Top Banner
LEARNING IPAD UICATALOG IN OBJC LESSON 2 Rich Helton [email protected] October 15, 2012
85
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: I pad uicatalog_lesson02

LEARNING  IPAD    UICATALOG  IN  OBJ-­‐C  

LESSON  2    

Rich  Helton  [email protected]  

October  15,  2012  

Page 2: I pad uicatalog_lesson02

INTRO  TO  UICATALOG  

Page 3: I pad uicatalog_lesson02

Disclaimer  –  For  EducaAonal  Purposes  •  This  training  PowerPoint  is  in  no  means  reproducing  the  documents  that  it  may  reference.  

•  Which  also  means  that  the  references  may  change  at  the  owners  will.    

•  It  only  provides  references  to  public  sites  as  a  means  for  the  person  reading  this  to  do  more  research  and  verify  any  informaAon  at  their  leisure.  

•  The  purpose  of  this  document’s  original  intent  was  simply  to  provide  myself  a  means  of  walking  through  various  soluAons  and  reference  points.    

•  I  offer  no  personal  support  of  this  document  and  release  it  “as  is”  with  no  commercial  intent.    

Page 4: I pad uicatalog_lesson02

UICatalog  -­‐-­‐  Apple  •  Apple  provides  a  sample  tutorial  for  various  UI  Controls  and  Views  called  UICatalog.  

•  This  sample  is  really  meant  for  the  iPhone,  but  I  will  likely  apply  some  iPad  to  it.    

•  See  hVp://developer.apple.com/library/ios/#samplecode/UICatalog  

Page 5: I pad uicatalog_lesson02

UICatalog  –  Why?  •  I  decided  to  walk  through  UICatalog  because  it  gives  various  samples  to  show  what  UiKit  can  do.  

•  I  also  decided  to  enhance  the  example  to  actually  be  more  iPad  like,  for  example,  Split  Views.    

Page 6: I pad uicatalog_lesson02

UICatalog  –  has  a  buVon  for  the  code  

Page 7: I pad uicatalog_lesson02

UICatalog  –  Readme.txt,  has  info  

Page 8: I pad uicatalog_lesson02

A  note  about  iPad  stencils…  •  There  is  always  the  need  to  mockup  the  Gui  before  development  for  good  requirements.  

•  There  are  many  iPad  stencils,  OmniGraffe  being  popular,  and  stencil  sets  at  places  like,  hVp://webdesignledger.com/freebies/11-­‐ui-­‐kits-­‐for-­‐iphone-­‐and-­‐ipad-­‐development    

•     

Page 9: I pad uicatalog_lesson02

Just  download  the  sample….  •  Run  it  in  the  iPad  5  Simulator:  

Page 10: I pad uicatalog_lesson02

IPAD  STENCILS  

Page 11: I pad uicatalog_lesson02

A  note  about  iPad  stencils…  •  There  is  always  the  need  to  mockup  the  Gui  before  development  for  good  requirements.  

•  There  are  many  iPad  stencils,  OmniGraffe  being  popular,  and  stencil  sets  at  places  like,  hVp://webdesignledger.com/freebies/11-­‐ui-­‐kits-­‐for-­‐iphone-­‐and-­‐ipad-­‐development    

•   These  are  good  tools,  and  for  some  of  them,  a  OS  X  operaAng  system  is  required,  be  it  MacBook  or  VMWare.    

Page 12: I pad uicatalog_lesson02

My  favorite…stencils…  •  For  my  purposes,  I  use  the  iOS  simulator,  Gimp,  hVp://www.gimp.org/  and  screen  grab  with  Command-­‐Shid-­‐4,  screen  shot  commands.    

Page 13: I pad uicatalog_lesson02

My  favorite…  •  Copying  from  the  Simulator,  we  can  just  cut  and  paste  icons,  and  various  screen  controls  for  our  stencils.    

•  Running  UIControl,  we  can  start  pasAng:  

Page 14: I pad uicatalog_lesson02

Gimp…  •  Cut  and  Paste,  we  can  move  the  GUI  around  for  size:  

Page 15: I pad uicatalog_lesson02

Gimp  DocumentaAon  •  Gimp  has  a  lot  of  documentaAon  found  at  hVp://docs.gimp.org/2.8/en/  :  

Page 16: I pad uicatalog_lesson02

So  where  are  we  now….  

•  We  can  create  new  screen  captures  and  combine  them  using  Gimp  to  see  what  a  GUI  may  look  like.  

•  We  can  grab  snippets  of  code  from  samples  like  UIControl  to  match  up  with  the  GUI.  

•  Capturing  from  different  samples,  and  using  cut  and  paste  screens  can  show  what  an  App  may  look  like  before  coding.    

Page 17: I pad uicatalog_lesson02

PIECES  AND  PARTS  

Page 18: I pad uicatalog_lesson02

The  Language….  •  We  are  doing  ObjecAve-­‐C  (Obj-­‐C)  in  this  example,  which  is  a  superset  of  the  C  language,  from  NeXTSTEP,    that  objecAfies  C  that  adds  Smalltalk-­‐style  messaging.  hVp://en.wikipedia.org/wiki/ObjecAve-­‐C    

•  We  could  have  built  the  App  in  straight  C,  C++,  ObjecAve-­‐C++,  or  even  C#.    

•  You  can  also  learn  Obj-­‐C  on  Windows  using  GnuStep,  hVp://en.wikipedia.org/wiki/GNUstep    

Page 19: I pad uicatalog_lesson02

UIKit.H    and  AppKit.H….  •  Also  note,  that  we  are  using  UIKit.h,  which  is  the  graphics  framework  for  iPad  and  iPhone,  and  part  of  Cocoa-­‐Touch,  hVp://en.wikipedia.org/wiki/Cocoa_Touch    

•  For  the  Mac  OSX,  we  would  be  using  Cocoa  and  AppKit.h.  hVp://en.wikipedia.org/wiki/Cocoa_(API)    

•  Most  kits  will  use  MVC,  which  is  design  paVern  in  most  Programming  Languages.    

Page 20: I pad uicatalog_lesson02

UIKit.H  ….  •  The  UIKit  Reference  can  be  found  at  hVp://developer.apple.com/library/ios/#documentaAon/UIKit/Reference/UIKit_Framework/_index.html    

Page 21: I pad uicatalog_lesson02

A  few  words  about  MVC  •  The  Model-­‐View-­‐Controller  (MVC):  

•  hVp://en.wikipedia.org/wiki/Model–view–controller    

Page 22: I pad uicatalog_lesson02

Main.m….  •  All  C,  C++,  and  C#  languages  will  start  with  a  Main  funcAon,  and  we  would  normally  find  ours  in  main.m:  

Page 23: I pad uicatalog_lesson02

MainViewController.m….  •  The  main  is  going  to  start  the  MainViewController::viewDidLoad  to  start  the  first  page  with  the  menuList:  

Page 24: I pad uicatalog_lesson02

MainViewController.m….  •  An  array  called  menuList  is  used  to  store  the  Controllers  from  the  main  page:  

Page 25: I pad uicatalog_lesson02

AppDelegate.m….  •  Ader  the  main  starts,  the  AppDelegate  gets  called  to  make  the  window  visible,  usually  in  the  applicaAonDidFinishLaunching  funcAon:  

Page 26: I pad uicatalog_lesson02

AppDelegate.h….  

Page 27: I pad uicatalog_lesson02

A  liVle  recap….  •  MVC  was  menAoned  earlier,  and  in  the  previous  slides,  we  have  a  UIApplicaAon,  navigaAonController,  and  window.  

•  Not  to  go  into  too  much  detail,  these  items  do  not  have  to  be  Coded  Objects,  but  can  be  delegated  .XIB  files.    

•  The  MainWindow.xib  will  be  called  from  the  AppDelegate  and  filled  in  by  the  MainViewController.    

Page 28: I pad uicatalog_lesson02

The  base  Window  •  The  Window,  MainViewController,  NavigaAon  bar  and  Appdelegate  are  ascoiated  with  each  other  in  the  MainWindow.xib:  

Page 29: I pad uicatalog_lesson02

UIView  •  All  the  Views,  Controls,  Windows,  and  Controllers  can  be  added  using  the  Interface  Builder:  

Page 30: I pad uicatalog_lesson02

SOME  BASIC  TERMINOLOGY  

Page 31: I pad uicatalog_lesson02

NIB  File     The  NIB  file  is  the  compiled  set  of  XIB  files,  the  XML,  for  the  App.    

   It  will  be  packaged  in  the  deployed  App.     hVp://developer.apple.com/library/mac/#documentaAon/Cocoa/Conceptual/LoadingResources/CocoaNibs/CocoaNibs.html    

Page 32: I pad uicatalog_lesson02

XIB  File     There  are  many  XML  file  formats  to  help  generate  GUI’s,  for  example  in  Microsod's  WPF,  there  is  the  XAML  file  format.    

   For  IOS,  it  is  the  XIB  file  format.    

 These  file  formats  offer  a  good  base  to  iniAalize  the  graphics  based  on  the  devices  grid  system,  but  Aghter  control  of  the  graphics  will  rely  on  the  MVC  code.    

Page 33: I pad uicatalog_lesson02

XIB  Code  GeneraAon  

 hVp://docs.xamarin.com/ios/advanced_topics/xib_code_generaAon    

Page 34: I pad uicatalog_lesson02

Interface  Builder     The  XIB  file  can  be  managed  in  Xcode’s  Interface  Builder.  

 See  hVp://en.wikipedia.org/wiki/Interface_Builder  

   Pro’s  and  Cons  of  IB  and  XIB  can  be  found  at  hVp://mobile.tutsplus.com/tutorials/iphone/interface-­‐builder/    

Page 35: I pad uicatalog_lesson02

AcAons  and  Outlets  •  Outlets  will  allow  Controllers  to  talk  to  the  View,  AcAons  will  allow  the  View  to  talk  to  the  Controller.    

•  The  AcAon  sends  a  message  to  a  target,  usually  through  a  “sender”  and  the  target  will  implement  a  responder.    

•  See  Cocoa  Fundamentals  Guide  hVps://developer.apple.com/library/mac/#documentaAon/Cocoa/Conceptual/CocoaFundamentals/CommunicaAngWithObjects/CommunicateWithObjects.html#//apple_ref/doc/uid/TP40002974-­‐CH7-­‐SW15    

Page 36: I pad uicatalog_lesson02

We  have  seen  Outlets  •  In  AppDelegate.h,  we  already  see  2  Outlets,  one  for  window,  and  one  for  navigaAonController  using  the  IBOutlet  keyword.    

Page 37: I pad uicatalog_lesson02

CocoaDev  on  Outlets  

Page 38: I pad uicatalog_lesson02

Some  AcAons…  •  In  ImagesViewController,  we  see  some  AcAons,  given  by  IBAcAon.    

Page 39: I pad uicatalog_lesson02

CocoaDev  on  AcAons  

Page 40: I pad uicatalog_lesson02

THE  CONTROLLERS  

Page 41: I pad uicatalog_lesson02

BuVonsViewController  •  StarAng  from  the  top  of  the  menuList  and  working  down,  we  have  the  BuVonsViewController:  

Page 42: I pad uicatalog_lesson02

BuVonsViewController.xib  

Page 43: I pad uicatalog_lesson02

BuVonsViewController.h  •  Declaring  the  BuVons.  

Page 44: I pad uicatalog_lesson02

BuVonsViewController.m  •  Define  the  BuVons.  

Page 45: I pad uicatalog_lesson02

ControlsViewController  

Page 46: I pad uicatalog_lesson02

ControlsViewController.xib  

Page 47: I pad uicatalog_lesson02

ControlsViewController.h  •  Declare  the  Controls.  

Page 48: I pad uicatalog_lesson02

ControlsViewController.m  •  Define  the  Controls.  

Page 49: I pad uicatalog_lesson02

TextFieldController  

Page 50: I pad uicatalog_lesson02

TextFieldController.xib  

Page 51: I pad uicatalog_lesson02

TextFieldController.h  •  Declare  the  TextFields.  

Page 52: I pad uicatalog_lesson02

TextFieldController.m  •  Define  the  TextFields.  

Page 53: I pad uicatalog_lesson02

SearchBarController  

Page 54: I pad uicatalog_lesson02

SearchBarController.xib  

Page 55: I pad uicatalog_lesson02

SearchBarController.h  •  Declare  the  SearchBar.  

Page 56: I pad uicatalog_lesson02

SearchBarController.m  •  Define  the  SearchBar.  

Page 57: I pad uicatalog_lesson02

TextViewController  

Page 58: I pad uicatalog_lesson02

TextViewController.xib  

Page 59: I pad uicatalog_lesson02

TextViewController.h  •  Declare  the  TextView.  

Page 60: I pad uicatalog_lesson02

TextViewController.m  •  Define  the  TextView.  

Page 61: I pad uicatalog_lesson02

ImagesViewController  

Page 62: I pad uicatalog_lesson02

ImagesViewController.xib  

Page 63: I pad uicatalog_lesson02

ImagesViewController.h  •  Declare  the  ImageView.  

Page 64: I pad uicatalog_lesson02

ImagesViewController.m  •  Define  the  ImageView.  

Page 65: I pad uicatalog_lesson02

WebViewController  

Page 66: I pad uicatalog_lesson02

WebViewController.xib  

Page 67: I pad uicatalog_lesson02

WebViewController.h  •  Declare  the  UIWebView.  

Page 68: I pad uicatalog_lesson02

WebViewController.m  •  Define  the  UIWebView.  

Page 69: I pad uicatalog_lesson02

SegmentViewController  

Page 70: I pad uicatalog_lesson02

SegmentViewController.xib  

Page 71: I pad uicatalog_lesson02

SegmentViewController.h  •  Declare  the  SegmentViewController.  

Page 72: I pad uicatalog_lesson02

SegmentViewController.m  •  Define  the  SegmentViewController.  

Page 73: I pad uicatalog_lesson02

ToolbarViewController  

Page 74: I pad uicatalog_lesson02

ToolbarViewController.xib  

Page 75: I pad uicatalog_lesson02

ToolbarViewController.h  •  Declare  the  toolbar.  

Page 76: I pad uicatalog_lesson02

ToolbarViewController.m  •  Define  the  toolbar.  

Page 77: I pad uicatalog_lesson02

AlertsViewController  

Page 78: I pad uicatalog_lesson02

AlertsViewController.xib  

Page 79: I pad uicatalog_lesson02

AlertsViewController.h  •  Declare  the  UIAlertViewDelegate.  

Page 80: I pad uicatalog_lesson02

AlertsViewController.m  •  Define  the  AcAon  Sheets.  

Page 81: I pad uicatalog_lesson02

TransiAonViewController  

Page 82: I pad uicatalog_lesson02

TransiAonViewController.xib  

Page 83: I pad uicatalog_lesson02

TransiAonViewController.h  •  Declare  the  Image  Views  and  senders.  

Page 84: I pad uicatalog_lesson02

TransiAonViewController.m  •  Define  the  Image  Views  and  senders.  

Page 85: I pad uicatalog_lesson02

CONCLUSION