SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
Chapter 7
               Natural born navigator
                      Bit Academy
•
               •
               •
                   .

               •
•


               •
               •     ViewController
                   ViewController
                           .
Navigation
               •   UIViewController : UIView

               •   UINavigationController : NavigationBar                    NavigationBar
                                                                         .

               •   UINavigationBar :                            , UINavigationController


               •   UINavigationItem :                                                UIViewController
                                , UINavigationBar                                , leftBarButtonItem,
                   rightBarButtonItem                                        .

               •   UIBarButtonItem :
                                                            , UIButton
                                  -
UIViewController Class

               •                              .   ,                .

               •
                                                        .

               •                                            NIB
                                   . NIB     IB
                                              .

               •                loadView              NIB
                   initWithNibName:bundle:                   NIB
                            .
Creating a View Controller Using Nib Files
                1   – initWithNibName:bundle:
                2     nibName  property
                3     nibBundle  property
               Managing the View
                1     view  property
                2   – loadView
                3   – viewDidLoad
                4   – viewDidUnload
                5   – isViewLoaded
                6     title  property
                7     contentSizeForViewInPopover  property
                8     modalInPopover  property
               Responding to View Events
                1   – viewWillAppear:
                2   – viewDidAppear:
                3   – viewWillDisappear:
                4   – viewDidDisappear:
               Configuring the View’s Layout Behavior
                1     wantsFullScreenLayout  property
               Configuring the View Rotation Settings
                1     interfaceOrientation  property
                2   – shouldAutorotateToInterfaceOrientation:
                3   – rotatingHeaderView
                4   – rotatingFooterView
               Responding to View Rotation Events
                1   – willRotateToInterfaceOrientation:duration:
                2   – willAnimateRotationToInterfaceOrientation:duration:
                3   – didRotateFromInterfaceOrientation:
                4   – willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
                5   – didAnimateFirstHalfOfRotationToInterfaceOrientation:
                6   – willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
Handling Memory Warnings
                1   – didReceiveMemoryWarning
               Getting Other Related View Controllers
                1     parentViewController  property
                2     searchDisplayController  property
                3     splitViewController  property
                4     modalViewController  property
                5     navigationController  property
                6     tabBarController  property
               Presenting Modal Views
                1   – presentModalViewController:animated:
                2   – dismissModalViewControllerAnimated:
                3     modalTransitionStyle  property
                4     modalPresentationStyle  property
                5   – disablesAutomaticKeyboardDismissal
               Configuring a Navigation Interface
                1     navigationItem  property
                2     editing  property
                3   – setEditing:animated:
                4   – editButtonItem
                5     hidesBottomBarWhenPushed  property
               Configuring the Navigation Controller’s Toolbar
                1   – setToolbarItems:animated:
                2     toolbarItems  property
               Configuring Tab Bar Items
                1     tabBarItem  property
UINavigationController Class
UIViewController : UIResponder : NSObject

                                                                                property

                      delegate : The receiver’s delegate or nil if it doesn’t have a delegate.
                      @property(nonatomic, assign) id<UINavigationControllerDelegate> delegate

                      navigationBar
                      The navigation bar managed by the navigation controller. (read-only)
                      @property(nonatomic, readonly) UINavigationBar *navigationBar


                      navigationBarHidden
                      A Boolean value that determines whether the navigation bar is hidden.
                      @property(nonatomic, getter=isNavigationBarHidden) BOOL navigationBarHidden

                      toolbar
                      The custom toolbar associated with the navigation controller. (read-only)
                      @property(nonatomic,readonly) UIToolbar *toolbar
                                       UIViewController setToolbarItems:animated:                       .
                      toolbarHidden
                      A Boolean indicating whether the navigation controller’s built-in toolbar is visible.
                      @property(nonatomic,getter=isToolbarHidden) BOOL toolbarHidden

                      topViewController
                      The view controller at the top of the navigation stack. (read-only)
                      @property(nonatomic, readonly, retain) UIViewController *topViewController

                      viewControllers
                      The view controllers currently on the navigation stack.
                      @property(nonatomic, copy) NSArray *viewControllers



                      visibleViewController
                      The view controller associated with the currently visible view in the navigation interface. (read-only)
                      @property(nonatomic, readonly, retain) UIViewController *visibleViewController
                                                               ViewController view                                              .
UINavigationController Class
          initWithRootViewController:
          Initializes and returns a newly created navigation controller.
          - (id)initWithRootViewController:(UIViewController *)rootViewController

          popToRootViewControllerAnimated:
          Pops all the view controllers on the stack except the root view controller and updates
          the display. (                                                         )
          - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated
          popToViewController:animated:
          Pops view controllers until the specified view controller is at the top of the navigation stack.
          - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated

          popViewControllerAnimated:
          Pops the top view controller from the navigation stack and updates the display.
          - (UIViewController *)popViewControllerAnimated:(BOOL)animated

          pushViewController:animated:
          Pushes a view controller onto the receiver’s stack and updates the display.
          - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated

          setNavigationBarHidden:animated:
          Sets whether the navigation bar is hidden.
          - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated

          setToolbarHidden:animated:
          Changes the visibility of the navigation controller’s built-in toolbar.
          - (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated
          setViewControllers:animated:
          Replaces the view controllers currently managed by the navigation controller with the specified items.
          - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
UINavigationController Delegate
                             Protocol
     delegate protocol   UINavigationController
                             delegate




                                    Instance Methods

      navigationController:didShowViewController:animated:
                                                  .
      - (void)navigationController:(UINavigationController *)navigationController
      didShowViewController:(UIViewController *)viewController animated:(BOOL)animated

      navigationController:willShowViewController:animated:
                                                   .
      - (void)navigationController:(UINavigationController *)navigationController
      willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
UINavigationBar Class
                                                                  property


                backItem
                The navigation item that is immediately below the topmost item on navigation bar’s stack. (read-
                only)
                @property(nonatomic, readonly, retain) UINavigationItem *backItem
                barStyle
                The appearance of the navigation bar.
                @property(nonatomic, assign) UIBarStyle barStyle


                delegate
                The navigation bar’s delegate object. NavigationController                  .
                @property(nonatomic, assign) id delegate

                items
                An array of navigation items managed by the navigation bar.
                @property(nonatomic, copy) NSArray *items
                Discussion
                The bottom item is at index 0, the back item is at index n-2, and the top item is at index n-1, where
                n is the number of items in the array.
                tintColor
                The color used to tint the bar.
                @property(nonatomic, retain) UIColor *tintColor

                topItem
                The navigation item at the top of the navigation bar’s stack. (read-only)
                @property(nonatomic, readonly, retain) UINavigationItem *topItem



                translucent
                A Boolean value indicating whether the navigation bar is only partially opaque.
                @property(nonatomic,assign,getter=isTranslucent) BOOL translucent
UINavigationBar Class
                                                   Instance
                   popNavigationItemAnimated:
                   Pops the top item from the receiver’s stack and updates the navigation
                   bar.
                   - (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated
                   pushNavigationItem:animated:
                   Pushes the given navigation item onto the receiver’s stack and updates
                   the navigation bar.
                   - (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)
                   animated
                   setItems:animated:
                   Replaces the navigation items currently managed by the navigation bar
                   with the specified items.
                   - (void)setItems:(NSArray *)items animated:(BOOL)animated

          UINavigationBar
                        . UINavigationController
          UINavigationController                                    .
UINavigationItem Class
                                                                 property
           backBarButtonItem
           The bar button item to use when this item is represented by a back button on the navigation bar.
           @property(nonatomic, retain) UIBarButtonItem *backBarButtonItem

           hidesBackButton
           A Boolean value that determines whether the back button is hidden.
           @property(nonatomic, assign) BOOL hidesBackButton

           leftBarButtonItem
           A custom bar item displayed on the left of the navigation bar when this item is the top item.
           @property(nonatomic, retain) UIBarButtonItem *leftBarButtonItem
           prompt
           A single line of text displayed at the top of the navigation bar.
           @property(nonatomic, copy) NSString *prompt
           rightBarButtonItem
           A custom bar item displayed on the right of the navigation bar when this item is the top item.
           @property(nonatomic, retain) UIBarButtonItem *rightBarButtonItem
           title
           The navigation item’s title displayed in the center of the navigation bar.
           @property(nonatomic, copy) NSString *title

           titleView
           A custom view displayed in the center of the navigation bar when this item is the top item.
           @property(nonatomic, retain) UIView *titleView
UINavigationItem Class
                                             Instance Method
               initWithTitle:
               Returns a navigation item initialized with the specified title.
               - (id)initWithTitle:(NSString *)title

               setHidesBackButton:animated:
               Sets whether the back button is hidden, optionally animating the transition.
               - (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated
               hidesBackButton                    .
               setLeftBarButtonItem:animated:
               Sets the custom bar item, optionally animating the transition to the view.
               - (void)setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated

               setRightBarButtonItem:animated:
               Sets the custom bar item, optionally animating the transition to the view.
               - (void)setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
UIBarButtonItem Class
                                                                     property

               action
               The selector defining the action message to send to the target object when the user taps this bar button item.
               @property(nonatomic) SEL action

               customView
               A custom view representing the item.
               @property(nonatomic, retain) UIView *customView

               possibleTitles
               The set of possible titles to display on the bar button.
               @property(nonatomic, copy) NSSet *possibleTitles


               style
               The style of the item.
               @property(nonatomic) UIBarButtonItemStyle style
               target
               The object that receives an action when the item is selected.
               @property(nonatomic, assign) id target
               width
               The width of the item.
               @property(nonatomic) CGFloat width
UIBarButtonItem Class
                                                 instance method
     initWithBarButtonSystemItem:target:action:
     Creates and returns a new item containing the specified system item.
     - (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target
     action:(SEL)action

     initWithCustomView:
     Creates and returns a new item using the specified custom view.

     - (id)initWithCustomView:(UIView *)customView


     initWithImage:style:target:action:
     Creates and returns a new item using the specified image and other properties.
     - (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target
     action:(SEL)action

     initWithTitle:style:target:action:
     Creates and returns a new item using the specified title and other properties.
     - (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target
     action:(SEL)action
- pushViewController:animated:


               -
               -                     navigationItem
               navigationBar
               - back

               navigationItem          navigationBar
•2
               •    :

               •1       :

               •2       :
UIImage Class

               •   A UIImage object is a high-level way to display image data. You
                   can create images from files, from Quartz image objects, or from
                   raw image data you receive.

               •   imageNamed:

                   Returns the image object associated with the specified filename.
                   + (UIImage *)imageNamed:(NSString *)name
CLLocation Class

               •   CLLocation          CLLocationManager object
                                  .             ,    ,                           .

               •   initWithLatitude:longitude:

                   Initializes and returns a location object with the specified
                   latitude and longitude.
                   - (id)initWithLatitude:(CLLocationDegrees)latitude
                     longitude:(CLLocationDegrees)longitude
MKMapView Class

               •   Map                   ,                      .

               •               region            , span(horizon & vertical
                   distance)                         .

               •                         (   )

               •               overlay
• File->NewProject
               • Navigation-based Application
               •                     : WorldPhotos

               • Window.xib
                    RootViewController.nib
WorldPhotosAppDelegate.h

                                                                         @interface WorldPhotosAppDelegate : NSObject <UIApplicationDelegate> {

                                                                             UIWindow *window;
                                                                             UINavigationController *navigationController;
WorldPhotosAppDelegate.m                                                 !
                                                                         !   NSArray *photoArray;
- (void)applicationDidFinishLaunching:(UIApplication *)application {     }
!   photoArray = [[NSArray alloc] initWithArray:[self createPhotoData]];
!   [window addSubview:[navigationController view]];                     - (NSArray *)createPhotoData;
    [window makeKeyAndVisible];
}                                                                        @property (nonatomic, retain) IBOutlet UIWindow *window;
                                                                         @property (nonatomic, retain) IBOutlet UINavigationController
- (NSArray *)createPhotoData                                             *navigationController;
{                                                                        @property (readonly) NSArray *photoArray;
!   CLLocation *location;                                                @end
!   UIImage *photo;
!   UIImage *thumbnail;
!
!   location = [[CLLocation alloc] initWithLatitude:31.048026 longitude:-7.13017];
!   photo = [UIImage imageNamed:@"Africa_Morocco_1.jpg"];
!   thumbnail = [UIImage imageNamed:@"Africa_Morocco_1_thumbnail.jpg"];
!   NSDictionary *africa_morroco = [NSDictionary dictionaryWithObjectsAndKeys:@"Africa", @"Region", @"Morocco", @"Country", photo,
@"Photo", thumbnail, @"Thumbnail", location, @"Location", nil];
!   [location release];              - method
!
!   location = [[CLLocation alloc] initWithLatitude:35.700884 longitude:139.770893];
!   photo = [UIImage imageNamed:@"Asia_Japan_1.jpg"];
!   thumbnail = [UIImage imageNamed:@"Asia_Japan_1_thumbnail.jpg"];
!   NSDictionary *asia_japan = [NSDictionary dictionaryWithObjectsAndKeys:@"Asia", @"Region", @"Japan", @"Country", photo, @"Photo",
thumbnail, @"Thumbnail", location, @"Location", nil];
!   [location release];
!
!   location = [[CLLocation alloc] initWithLatitude:46.981248 longitude:8.253908];
!   photo = [UIImage imageNamed:@"Europe_Swiss_1.jpg"];
!   thumbnail = [UIImage imageNamed:@"Europe_Swiss_1_thumbnail.jpg"];
!   NSDictionary *europe_swiss = [NSDictionary dictionaryWithObjectsAndKeys:@"Europe", @"Region", @"Swiss", @"Country", photo, @"Photo",
thumbnail, @"Thumbnail", location, @"Location", nil];
!   [location release];
!
!   NSArray *returnArray = [NSArray arrayWithObjects:africa_morroco, asia_japan, europe_swiss, nil];
!   return returnArray;
}
,
RootViewController.m

@implementation RootViewController
                                                                                   RootViewController.h
- (void)viewDidLoad {
    [super viewDidLoad];                                                           @class WorldPhotosAppDelegate;
!   self.navigationItem.title = @"World Photos";
}                                                                                  @interface RootViewController : UITableViewController {
                                                                                   }
- (WorldPhotosAppDelegate *)appDelegate
{                                                                                  - (WorldPhotosAppDelegate *)appDelegate;
!   return [[UIApplication sharedApplication] delegate];                           @end
}

#pragma mark Table view methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { //optional
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [[self appDelegate].photoArray count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

!   NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row];
!
!   cell.textLabel.text = [photoData valueForKey:@"Country"];
!   cell.detailTextLabel.text = [photoData valueForKey:@"Region"];
!   cell.imageView.image = [photoData valueForKey:@"Thumbnail"];
!   cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
!   PhotoDetailViewController *detailViewController = [[PhotoDetailViewController alloc]
initWithNibName:@"PhotoDetailViewController" bundle:nil];
!   NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row];
!   detailViewController.photoData = photoData;
!   [self.navigationController pushViewController:detailViewController animated:YES];
!   [detailViewController release];
}
,

-
file->new            Choose template             UIViewController subclass
PhotoDetailViewController                      . PhotoDetailViewController.h .m .xib                  .

PhotoDetailView.xib                    IB                               ImageView
UIView                        &          .

PhotoDetailView.h                                              NSDictionary       photoData,
                                 UIImageView            OutLet photoImageView,
                             UIBarButtonItem           OutLet mapBarButton
mapBarButton                                          goToMapView:                      .

                          Bar Button Items Nib                          &              mapBarButton           , Map
               .          photoDetailViewController                                            .

mapBarButton           File’s Owner   PhotoDetailViewController    -goToMapView:                          .
                   .

                                   PhotoViewController                        view                                -viewDidLoad
                         . rightBarButtonItem        view
PhotoDetailViewController.h .m
                                                                    PhotoDetailViewController.h

                                                                    @interface PhotoDetailViewController : UIViewController {
                                                                    !   NSDictionary *photoData;
                                                                    !   UIImageView *photoImageView;
                                                                    !
                                                                    !   UIBarButtonItem *mapBarButton;
                                                                    }

                                                                    - (IBAction)goToMapView:(id)sender;

                                                                    @property (retain) NSDictionary *photoData;
                                                                    @property (nonatomic, retain) IBOutlet UIImageView *photoImageView;
                                                                    @property (nonatomic, retain) IBOutlet UIBarButtonItem *mapBarButton;

                                                                    @end

     PhotoDetailViewController.m
     #import "PhotoDetailViewController.h"
     #import "PhotoMapViewController.h"

     @implementation PhotoDetailViewController

     @synthesize photoData;
     @synthesize photoImageView;
     @synthesize mapBarButton;

     - (void)viewDidLoad {
         [super viewDidLoad];
     !   self.navigationItem.rightBarButtonItem = mapBarButton;
     !   photoImageView.image = [photoData valueForKey:@"Photo"];
     }

     - (void)dealloc {
     !   [photoData release];
     !   [photoImageView release];
     !   [mapBarButton release];
         [super dealloc];
     }

     - (IBAction)goToMapView:(id)sender
     {
     !    PhotoMapViewController *mapViewController = [[PhotoMapViewController alloc] initWithNibName:@"PhotoMapViewController"
     bundle:nil];
     !    mapViewController.photoData = photoData;
     !    [self.navigationController pushViewController:mapViewController animated:YES];
     !    [mapViewController release];
     }
     @end
RootViewController.m

          - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)
          indexPath {
          !   PhotoDetailViewController *detailViewController = [[PhotoDetailViewController
          alloc] initWithNibName:@"PhotoDetailViewController" bundle:nil];
          !   NSDictionary *photoData = [[self appDelegate].photoArray
          objectAtIndex:indexPath.row];
          !   detailViewController.photoData = photoData;
          !   [self.navigationController pushViewController:detailViewController animated:YES];
          !   [detailViewController release];
          }



                                                                                                       ,

                initWithNibName:bundle:
                Returns a newly initialized view controller with the nib file in the specified bundle.

                - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle
                Parameters
                nibName
                The name of the nib file to associate with the view controller. The nib file name should not contain any leading path
                information. If you specify nil, the nibName property is set to nil.
                nibBundle
                The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project
                directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle.
                Return Value
                A newly initialized UIViewController object.
,




               •   File->New File                                   UIViewController subclass
                           with XIB for user interface

               •                          PhotoMapViewController            .

               •   PhotoMapViewController.xib     IB             Simulated User Interface
                   Elements       Top Bar                                    .

               •                          MapView
                          UIView                             &          .
PhotoMapViewController.h .m
               PhotoMapViewController.h

               @interface PhotoMapViewController : UIViewController <MKMapViewDelegate> {
               !   NSDictionary *photoData;
               !   MKMapView *mapView;
               }

               @property (retain) NSDictionary *photoData;
               @property (nonatomic, retain) IBOutlet MKMapView *mapView;

               @end

               #import "PhotoMapViewController.h"

               @implementation PhotoMapViewController

               @synthesize mapView;
               @synthesize photoData;
                                                                              0      1                      1   111km
               - (void)viewDidLoad {
                   [super viewDidLoad];
               !   mapView.delegate = self;
               !
               }

               - (void)viewWillAppear:(BOOL)animated
               {
               !   CLLocation *location = [photoData valueForKey:@"Location"];
               !   MKCoordinateSpan span = MKCoordinateSpanMake(0.1, 0.1);
               !   MKCoordinateRegion region = MKCoordinateRegionMake(location.coordinate, span);
               !   [mapView setRegion:region animated:YES];
               }

               - (void)dealloc {
               !
               !
                   [photoData release];
                   [mapView release];
                                              setRegion:animated:
                   [super dealloc];           Changes the currently visible region and optionally animates the change.
               }
                                              - (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated
               @end                           Parameters
                                              region
                                              The new region to display in the map view.
                                              animated
                                              Specify YES if you want the map view to animate the transition to the new region or NO if
                                              you want the map to center on the specified region immediately
•   PhotoDetailViewController   PhotoMapViewController
                                           Map               .

               •           callback   PhotoDetailViewController   -goToMapView:
                           .

               •                PhotoMapViewController
                                  pushViewController:
                                   MapView             .
-goToMapView:

               PhotoDetailViewController.m

               - (IBAction)goToMapView:(id)sender
               {
               !   PhotoMapViewController *mapViewController = [[PhotoMapViewController alloc]
               initWithNibName:@"PhotoMapViewController" bundle:nil];
               !   mapViewController.photoData = photoData;
               !   [self.navigationController pushViewController:mapViewController animated:YES];
               !   [mapViewController release];
               }




                           UIViewController Class

                           navigationController
                           A parent or ancestor that is a navigation controller. (read-only)

                           @property(nonatomic, readonly, retain) UINavigationController
                           *navigationController
                           Discussion
                           Only returns a navigation controller if the view controller is in its stack. This property is nil if a navigation
                           controller cannot be found.

Más contenido relacionado

Destacado

Red Ventures - About Us
Red Ventures - About UsRed Ventures - About Us
Red Ventures - About UsMatt_Gostelow
 
Sap &amp; Oracle Roles - London
Sap &amp; Oracle Roles - LondonSap &amp; Oracle Roles - London
Sap &amp; Oracle Roles - LondonMatt_Gostelow
 
Eden Terrace Assisted Living, &quot;The Big Event&quot;
Eden Terrace Assisted Living, &quot;The Big Event&quot;Eden Terrace Assisted Living, &quot;The Big Event&quot;
Eden Terrace Assisted Living, &quot;The Big Event&quot;kristinbunton
 
아이폰강의(7) pdf
아이폰강의(7) pdf아이폰강의(7) pdf
아이폰강의(7) pdfsunwooindia
 
아이폰강의(4) pdf
아이폰강의(4) pdf아이폰강의(4) pdf
아이폰강의(4) pdfsunwooindia
 
2011년 상반기 스마트폰이용실태조사 요약보고서
2011년 상반기 스마트폰이용실태조사 요약보고서2011년 상반기 스마트폰이용실태조사 요약보고서
2011년 상반기 스마트폰이용실태조사 요약보고서sunwooindia
 
아이폰프로그래밍(2)
아이폰프로그래밍(2)아이폰프로그래밍(2)
아이폰프로그래밍(2)sunwooindia
 
아이폰강의(6) pdf
아이폰강의(6) pdf아이폰강의(6) pdf
아이폰강의(6) pdfsunwooindia
 
아이폰강의(3)
아이폰강의(3)아이폰강의(3)
아이폰강의(3)sunwooindia
 
2011 Malibu Mag Media Kit
2011 Malibu Mag Media Kit2011 Malibu Mag Media Kit
2011 Malibu Mag Media Kitjenniferfitz
 
Clinical management of anestrum
Clinical management of anestrumClinical management of anestrum
Clinical management of anestrumAyman Atef
 
Hereditary causes of infertility 1
Hereditary causes of infertility 1Hereditary causes of infertility 1
Hereditary causes of infertility 1Ayman Atef
 
Hereditary causes of infertility 2
Hereditary causes of infertility 2Hereditary causes of infertility 2
Hereditary causes of infertility 2Ayman Atef
 
Hormonal causes of infertility
Hormonal causes of infertilityHormonal causes of infertility
Hormonal causes of infertilityAyman Atef
 
Endocrine regulation of reproduction
Endocrine regulation of reproductionEndocrine regulation of reproduction
Endocrine regulation of reproductionAyman Atef
 

Destacado (17)

Minas Gerais - Your trade partner in Brazil
Minas Gerais - Your trade partner in BrazilMinas Gerais - Your trade partner in Brazil
Minas Gerais - Your trade partner in Brazil
 
2010 Minas Gerais Foreign Trade Outlook
2010 Minas Gerais Foreign Trade Outlook2010 Minas Gerais Foreign Trade Outlook
2010 Minas Gerais Foreign Trade Outlook
 
Red Ventures - About Us
Red Ventures - About UsRed Ventures - About Us
Red Ventures - About Us
 
Sap &amp; Oracle Roles - London
Sap &amp; Oracle Roles - LondonSap &amp; Oracle Roles - London
Sap &amp; Oracle Roles - London
 
Eden Terrace Assisted Living, &quot;The Big Event&quot;
Eden Terrace Assisted Living, &quot;The Big Event&quot;Eden Terrace Assisted Living, &quot;The Big Event&quot;
Eden Terrace Assisted Living, &quot;The Big Event&quot;
 
아이폰강의(7) pdf
아이폰강의(7) pdf아이폰강의(7) pdf
아이폰강의(7) pdf
 
아이폰강의(4) pdf
아이폰강의(4) pdf아이폰강의(4) pdf
아이폰강의(4) pdf
 
2011년 상반기 스마트폰이용실태조사 요약보고서
2011년 상반기 스마트폰이용실태조사 요약보고서2011년 상반기 스마트폰이용실태조사 요약보고서
2011년 상반기 스마트폰이용실태조사 요약보고서
 
아이폰프로그래밍(2)
아이폰프로그래밍(2)아이폰프로그래밍(2)
아이폰프로그래밍(2)
 
아이폰강의(6) pdf
아이폰강의(6) pdf아이폰강의(6) pdf
아이폰강의(6) pdf
 
아이폰강의(3)
아이폰강의(3)아이폰강의(3)
아이폰강의(3)
 
2011 Malibu Mag Media Kit
2011 Malibu Mag Media Kit2011 Malibu Mag Media Kit
2011 Malibu Mag Media Kit
 
Clinical management of anestrum
Clinical management of anestrumClinical management of anestrum
Clinical management of anestrum
 
Hereditary causes of infertility 1
Hereditary causes of infertility 1Hereditary causes of infertility 1
Hereditary causes of infertility 1
 
Hereditary causes of infertility 2
Hereditary causes of infertility 2Hereditary causes of infertility 2
Hereditary causes of infertility 2
 
Hormonal causes of infertility
Hormonal causes of infertilityHormonal causes of infertility
Hormonal causes of infertility
 
Endocrine regulation of reproduction
Endocrine regulation of reproductionEndocrine regulation of reproduction
Endocrine regulation of reproduction
 

Similar a 아이폰강의(5) pdf

iPhone Development: Multiple Views
iPhone Development: Multiple ViewsiPhone Development: Multiple Views
iPhone Development: Multiple ViewsJussi Pohjolainen
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barVu Tran Lam
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Manykenatmxm
 
April iOS Meetup - UIAppearance Presentation
April iOS Meetup - UIAppearance PresentationApril iOS Meetup - UIAppearance Presentation
April iOS Meetup - UIAppearance PresentationLong Weekend LLC
 
storyboard時代のInterfaceBuilder
storyboard時代のInterfaceBuilderstoryboard時代のInterfaceBuilder
storyboard時代のInterfaceBuilderHiroyuki Fujikawa
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View ControllersBob McCune
 
Using view controllers wisely
Using view controllers wiselyUsing view controllers wisely
Using view controllers wiselydefagos
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Michael Shrove
 
December 2014 University iOS Meetup Talk
December 2014 University iOS Meetup TalkDecember 2014 University iOS Meetup Talk
December 2014 University iOS Meetup Talkjcgohlke
 
Everything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View ControllersEverything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View ControllersBrian Gesiak
 
iOS: Implementing a Custom View
iOS: Implementing a Custom ViewiOS: Implementing a Custom View
iOS: Implementing a Custom ViewJussi Pohjolainen
 
Storytelling with storyboard part2
Storytelling with storyboard part2Storytelling with storyboard part2
Storytelling with storyboard part2nolili
 

Similar a 아이폰강의(5) pdf (20)

iPhone Development: Multiple Views
iPhone Development: Multiple ViewsiPhone Development: Multiple Views
iPhone Development: Multiple Views
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab bar
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Many
 
iOS: View Controllers
iOS: View ControllersiOS: View Controllers
iOS: View Controllers
 
April iOS Meetup - UIAppearance Presentation
April iOS Meetup - UIAppearance PresentationApril iOS Meetup - UIAppearance Presentation
April iOS Meetup - UIAppearance Presentation
 
storyboard時代のInterfaceBuilder
storyboard時代のInterfaceBuilderstoryboard時代のInterfaceBuilder
storyboard時代のInterfaceBuilder
 
Creating Container View Controllers
Creating Container View ControllersCreating Container View Controllers
Creating Container View Controllers
 
Using view controllers wisely
Using view controllers wiselyUsing view controllers wisely
Using view controllers wisely
 
I os 11
I os 11I os 11
I os 11
 
004
004004
004
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
 
IOS APPs Revision
IOS APPs RevisionIOS APPs Revision
IOS APPs Revision
 
December 2014 University iOS Meetup Talk
December 2014 University iOS Meetup TalkDecember 2014 University iOS Meetup Talk
December 2014 University iOS Meetup Talk
 
Everything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View ControllersEverything You (N)ever Wanted to Know about Testing View Controllers
Everything You (N)ever Wanted to Know about Testing View Controllers
 
Swf2 ui
Swf2 uiSwf2 ui
Swf2 ui
 
SwiftでUIKitDynamics
SwiftでUIKitDynamicsSwiftでUIKitDynamics
SwiftでUIKitDynamics
 
Objective c design pattens-architetcure
Objective c design pattens-architetcureObjective c design pattens-architetcure
Objective c design pattens-architetcure
 
IOS- Designing with ui tool bar in ios
IOS-  Designing with ui tool bar in iosIOS-  Designing with ui tool bar in ios
IOS- Designing with ui tool bar in ios
 
iOS: Implementing a Custom View
iOS: Implementing a Custom ViewiOS: Implementing a Custom View
iOS: Implementing a Custom View
 
Storytelling with storyboard part2
Storytelling with storyboard part2Storytelling with storyboard part2
Storytelling with storyboard part2
 

Último

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

아이폰강의(5) pdf

  • 1. Chapter 7 Natural born navigator Bit Academy
  • 2. • • . •
  • 3. • • ViewController ViewController .
  • 4.
  • 5. Navigation • UIViewController : UIView • UINavigationController : NavigationBar NavigationBar . • UINavigationBar : , UINavigationController • UINavigationItem : UIViewController , UINavigationBar , leftBarButtonItem, rightBarButtonItem . • UIBarButtonItem : , UIButton -
  • 6. UIViewController Class • . , . • . • NIB . NIB IB . • loadView NIB initWithNibName:bundle: NIB .
  • 7. Creating a View Controller Using Nib Files 1 – initWithNibName:bundle: 2   nibName  property 3   nibBundle  property Managing the View 1   view  property 2 – loadView 3 – viewDidLoad 4 – viewDidUnload 5 – isViewLoaded 6   title  property 7   contentSizeForViewInPopover  property 8   modalInPopover  property Responding to View Events 1 – viewWillAppear: 2 – viewDidAppear: 3 – viewWillDisappear: 4 – viewDidDisappear: Configuring the View’s Layout Behavior 1   wantsFullScreenLayout  property Configuring the View Rotation Settings 1   interfaceOrientation  property 2 – shouldAutorotateToInterfaceOrientation: 3 – rotatingHeaderView 4 – rotatingFooterView Responding to View Rotation Events 1 – willRotateToInterfaceOrientation:duration: 2 – willAnimateRotationToInterfaceOrientation:duration: 3 – didRotateFromInterfaceOrientation: 4 – willAnimateFirstHalfOfRotationToInterfaceOrientation:duration: 5 – didAnimateFirstHalfOfRotationToInterfaceOrientation: 6 – willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
  • 8. Handling Memory Warnings 1 – didReceiveMemoryWarning Getting Other Related View Controllers 1   parentViewController  property 2   searchDisplayController  property 3   splitViewController  property 4   modalViewController  property 5   navigationController  property 6   tabBarController  property Presenting Modal Views 1 – presentModalViewController:animated: 2 – dismissModalViewControllerAnimated: 3   modalTransitionStyle  property 4   modalPresentationStyle  property 5 – disablesAutomaticKeyboardDismissal Configuring a Navigation Interface 1   navigationItem  property 2   editing  property 3 – setEditing:animated: 4 – editButtonItem 5   hidesBottomBarWhenPushed  property Configuring the Navigation Controller’s Toolbar 1 – setToolbarItems:animated: 2   toolbarItems  property Configuring Tab Bar Items 1   tabBarItem  property
  • 9. UINavigationController Class UIViewController : UIResponder : NSObject property delegate : The receiver’s delegate or nil if it doesn’t have a delegate. @property(nonatomic, assign) id<UINavigationControllerDelegate> delegate navigationBar The navigation bar managed by the navigation controller. (read-only) @property(nonatomic, readonly) UINavigationBar *navigationBar navigationBarHidden A Boolean value that determines whether the navigation bar is hidden. @property(nonatomic, getter=isNavigationBarHidden) BOOL navigationBarHidden toolbar The custom toolbar associated with the navigation controller. (read-only) @property(nonatomic,readonly) UIToolbar *toolbar UIViewController setToolbarItems:animated: . toolbarHidden A Boolean indicating whether the navigation controller’s built-in toolbar is visible. @property(nonatomic,getter=isToolbarHidden) BOOL toolbarHidden topViewController The view controller at the top of the navigation stack. (read-only) @property(nonatomic, readonly, retain) UIViewController *topViewController viewControllers The view controllers currently on the navigation stack. @property(nonatomic, copy) NSArray *viewControllers visibleViewController The view controller associated with the currently visible view in the navigation interface. (read-only) @property(nonatomic, readonly, retain) UIViewController *visibleViewController ViewController view .
  • 10. UINavigationController Class initWithRootViewController: Initializes and returns a newly created navigation controller. - (id)initWithRootViewController:(UIViewController *)rootViewController popToRootViewControllerAnimated: Pops all the view controllers on the stack except the root view controller and updates the display. ( ) - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated popToViewController:animated: Pops view controllers until the specified view controller is at the top of the navigation stack. - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated popViewControllerAnimated: Pops the top view controller from the navigation stack and updates the display. - (UIViewController *)popViewControllerAnimated:(BOOL)animated pushViewController:animated: Pushes a view controller onto the receiver’s stack and updates the display. - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated setNavigationBarHidden:animated: Sets whether the navigation bar is hidden. - (void)setNavigationBarHidden:(BOOL)hidden animated:(BOOL)animated setToolbarHidden:animated: Changes the visibility of the navigation controller’s built-in toolbar. - (void)setToolbarHidden:(BOOL)hidden animated:(BOOL)animated setViewControllers:animated: Replaces the view controllers currently managed by the navigation controller with the specified items. - (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated
  • 11. UINavigationController Delegate Protocol delegate protocol UINavigationController delegate Instance Methods navigationController:didShowViewController:animated: . - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated navigationController:willShowViewController:animated: . - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
  • 12. UINavigationBar Class property backItem The navigation item that is immediately below the topmost item on navigation bar’s stack. (read- only) @property(nonatomic, readonly, retain) UINavigationItem *backItem barStyle The appearance of the navigation bar. @property(nonatomic, assign) UIBarStyle barStyle delegate The navigation bar’s delegate object. NavigationController . @property(nonatomic, assign) id delegate items An array of navigation items managed by the navigation bar. @property(nonatomic, copy) NSArray *items Discussion The bottom item is at index 0, the back item is at index n-2, and the top item is at index n-1, where n is the number of items in the array. tintColor The color used to tint the bar. @property(nonatomic, retain) UIColor *tintColor topItem The navigation item at the top of the navigation bar’s stack. (read-only) @property(nonatomic, readonly, retain) UINavigationItem *topItem translucent A Boolean value indicating whether the navigation bar is only partially opaque. @property(nonatomic,assign,getter=isTranslucent) BOOL translucent
  • 13. UINavigationBar Class Instance popNavigationItemAnimated: Pops the top item from the receiver’s stack and updates the navigation bar. - (UINavigationItem *)popNavigationItemAnimated:(BOOL)animated pushNavigationItem:animated: Pushes the given navigation item onto the receiver’s stack and updates the navigation bar. - (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL) animated setItems:animated: Replaces the navigation items currently managed by the navigation bar with the specified items. - (void)setItems:(NSArray *)items animated:(BOOL)animated UINavigationBar . UINavigationController UINavigationController .
  • 14. UINavigationItem Class property backBarButtonItem The bar button item to use when this item is represented by a back button on the navigation bar. @property(nonatomic, retain) UIBarButtonItem *backBarButtonItem hidesBackButton A Boolean value that determines whether the back button is hidden. @property(nonatomic, assign) BOOL hidesBackButton leftBarButtonItem A custom bar item displayed on the left of the navigation bar when this item is the top item. @property(nonatomic, retain) UIBarButtonItem *leftBarButtonItem prompt A single line of text displayed at the top of the navigation bar. @property(nonatomic, copy) NSString *prompt rightBarButtonItem A custom bar item displayed on the right of the navigation bar when this item is the top item. @property(nonatomic, retain) UIBarButtonItem *rightBarButtonItem title The navigation item’s title displayed in the center of the navigation bar. @property(nonatomic, copy) NSString *title titleView A custom view displayed in the center of the navigation bar when this item is the top item. @property(nonatomic, retain) UIView *titleView
  • 15. UINavigationItem Class Instance Method initWithTitle: Returns a navigation item initialized with the specified title. - (id)initWithTitle:(NSString *)title setHidesBackButton:animated: Sets whether the back button is hidden, optionally animating the transition. - (void)setHidesBackButton:(BOOL)hidesBackButton animated:(BOOL)animated hidesBackButton . setLeftBarButtonItem:animated: Sets the custom bar item, optionally animating the transition to the view. - (void)setLeftBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated setRightBarButtonItem:animated: Sets the custom bar item, optionally animating the transition to the view. - (void)setRightBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated
  • 16. UIBarButtonItem Class property action The selector defining the action message to send to the target object when the user taps this bar button item. @property(nonatomic) SEL action customView A custom view representing the item. @property(nonatomic, retain) UIView *customView possibleTitles The set of possible titles to display on the bar button. @property(nonatomic, copy) NSSet *possibleTitles style The style of the item. @property(nonatomic) UIBarButtonItemStyle style target The object that receives an action when the item is selected. @property(nonatomic, assign) id target width The width of the item. @property(nonatomic) CGFloat width
  • 17. UIBarButtonItem Class instance method initWithBarButtonSystemItem:target:action: Creates and returns a new item containing the specified system item. - (id)initWithBarButtonSystemItem:(UIBarButtonSystemItem)systemItem target:(id)target action:(SEL)action initWithCustomView: Creates and returns a new item using the specified custom view. - (id)initWithCustomView:(UIView *)customView initWithImage:style:target:action: Creates and returns a new item using the specified image and other properties. - (id)initWithImage:(UIImage *)image style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action initWithTitle:style:target:action: Creates and returns a new item using the specified title and other properties. - (id)initWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style target:(id)target action:(SEL)action
  • 18. - pushViewController:animated: - - navigationItem navigationBar - back navigationItem navigationBar
  • 19. •2 • : •1 : •2 :
  • 20. UIImage Class • A UIImage object is a high-level way to display image data. You can create images from files, from Quartz image objects, or from raw image data you receive. • imageNamed: Returns the image object associated with the specified filename. + (UIImage *)imageNamed:(NSString *)name
  • 21. CLLocation Class • CLLocation CLLocationManager object . , , . • initWithLatitude:longitude: Initializes and returns a location object with the specified latitude and longitude. - (id)initWithLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude
  • 22. MKMapView Class • Map , . • region , span(horizon & vertical distance) . • ( ) • overlay
  • 23. • File->NewProject • Navigation-based Application • : WorldPhotos • Window.xib RootViewController.nib
  • 24. WorldPhotosAppDelegate.h @interface WorldPhotosAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; UINavigationController *navigationController; WorldPhotosAppDelegate.m ! ! NSArray *photoArray; - (void)applicationDidFinishLaunching:(UIApplication *)application { } ! photoArray = [[NSArray alloc] initWithArray:[self createPhotoData]]; ! [window addSubview:[navigationController view]]; - (NSArray *)createPhotoData; [window makeKeyAndVisible]; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UINavigationController - (NSArray *)createPhotoData *navigationController; { @property (readonly) NSArray *photoArray; ! CLLocation *location; @end ! UIImage *photo; ! UIImage *thumbnail; ! ! location = [[CLLocation alloc] initWithLatitude:31.048026 longitude:-7.13017]; ! photo = [UIImage imageNamed:@"Africa_Morocco_1.jpg"]; ! thumbnail = [UIImage imageNamed:@"Africa_Morocco_1_thumbnail.jpg"]; ! NSDictionary *africa_morroco = [NSDictionary dictionaryWithObjectsAndKeys:@"Africa", @"Region", @"Morocco", @"Country", photo, @"Photo", thumbnail, @"Thumbnail", location, @"Location", nil]; ! [location release]; - method ! ! location = [[CLLocation alloc] initWithLatitude:35.700884 longitude:139.770893]; ! photo = [UIImage imageNamed:@"Asia_Japan_1.jpg"]; ! thumbnail = [UIImage imageNamed:@"Asia_Japan_1_thumbnail.jpg"]; ! NSDictionary *asia_japan = [NSDictionary dictionaryWithObjectsAndKeys:@"Asia", @"Region", @"Japan", @"Country", photo, @"Photo", thumbnail, @"Thumbnail", location, @"Location", nil]; ! [location release]; ! ! location = [[CLLocation alloc] initWithLatitude:46.981248 longitude:8.253908]; ! photo = [UIImage imageNamed:@"Europe_Swiss_1.jpg"]; ! thumbnail = [UIImage imageNamed:@"Europe_Swiss_1_thumbnail.jpg"]; ! NSDictionary *europe_swiss = [NSDictionary dictionaryWithObjectsAndKeys:@"Europe", @"Region", @"Swiss", @"Country", photo, @"Photo", thumbnail, @"Thumbnail", location, @"Location", nil]; ! [location release]; ! ! NSArray *returnArray = [NSArray arrayWithObjects:africa_morroco, asia_japan, europe_swiss, nil]; ! return returnArray; }
  • 25. , RootViewController.m @implementation RootViewController RootViewController.h - (void)viewDidLoad { [super viewDidLoad]; @class WorldPhotosAppDelegate; ! self.navigationItem.title = @"World Photos"; } @interface RootViewController : UITableViewController { } - (WorldPhotosAppDelegate *)appDelegate { - (WorldPhotosAppDelegate *)appDelegate; ! return [[UIApplication sharedApplication] delegate]; @end } #pragma mark Table view methods - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { //optional return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[self appDelegate].photoArray count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease]; } ! NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row]; ! ! cell.textLabel.text = [photoData valueForKey:@"Country"]; ! cell.detailTextLabel.text = [photoData valueForKey:@"Region"]; ! cell.imageView.image = [photoData valueForKey:@"Thumbnail"]; ! cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { ! PhotoDetailViewController *detailViewController = [[PhotoDetailViewController alloc] initWithNibName:@"PhotoDetailViewController" bundle:nil]; ! NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row]; ! detailViewController.photoData = photoData; ! [self.navigationController pushViewController:detailViewController animated:YES]; ! [detailViewController release]; }
  • 26. , - file->new Choose template UIViewController subclass PhotoDetailViewController . PhotoDetailViewController.h .m .xib . PhotoDetailView.xib IB ImageView UIView & . PhotoDetailView.h NSDictionary photoData, UIImageView OutLet photoImageView, UIBarButtonItem OutLet mapBarButton mapBarButton goToMapView: . Bar Button Items Nib & mapBarButton , Map . photoDetailViewController . mapBarButton File’s Owner PhotoDetailViewController -goToMapView: . . PhotoViewController view -viewDidLoad . rightBarButtonItem view
  • 27. PhotoDetailViewController.h .m PhotoDetailViewController.h @interface PhotoDetailViewController : UIViewController { ! NSDictionary *photoData; ! UIImageView *photoImageView; ! ! UIBarButtonItem *mapBarButton; } - (IBAction)goToMapView:(id)sender; @property (retain) NSDictionary *photoData; @property (nonatomic, retain) IBOutlet UIImageView *photoImageView; @property (nonatomic, retain) IBOutlet UIBarButtonItem *mapBarButton; @end PhotoDetailViewController.m #import "PhotoDetailViewController.h" #import "PhotoMapViewController.h" @implementation PhotoDetailViewController @synthesize photoData; @synthesize photoImageView; @synthesize mapBarButton; - (void)viewDidLoad { [super viewDidLoad]; ! self.navigationItem.rightBarButtonItem = mapBarButton; ! photoImageView.image = [photoData valueForKey:@"Photo"]; } - (void)dealloc { ! [photoData release]; ! [photoImageView release]; ! [mapBarButton release]; [super dealloc]; } - (IBAction)goToMapView:(id)sender { ! PhotoMapViewController *mapViewController = [[PhotoMapViewController alloc] initWithNibName:@"PhotoMapViewController" bundle:nil]; ! mapViewController.photoData = photoData; ! [self.navigationController pushViewController:mapViewController animated:YES]; ! [mapViewController release]; } @end
  • 28. RootViewController.m - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *) indexPath { ! PhotoDetailViewController *detailViewController = [[PhotoDetailViewController alloc] initWithNibName:@"PhotoDetailViewController" bundle:nil]; ! NSDictionary *photoData = [[self appDelegate].photoArray objectAtIndex:indexPath.row]; ! detailViewController.photoData = photoData; ! [self.navigationController pushViewController:detailViewController animated:YES]; ! [detailViewController release]; } , initWithNibName:bundle: Returns a newly initialized view controller with the nib file in the specified bundle. - (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)nibBundle Parameters nibName The name of the nib file to associate with the view controller. The nib file name should not contain any leading path information. If you specify nil, the nibName property is set to nil. nibBundle The bundle in which to search for the nib file. This method looks for the nib file in the bundle's language-specific project directories first, followed by the Resources directory. If nil, this method looks for the nib file in the main bundle. Return Value A newly initialized UIViewController object.
  • 29. , • File->New File UIViewController subclass with XIB for user interface • PhotoMapViewController . • PhotoMapViewController.xib IB Simulated User Interface Elements Top Bar . • MapView UIView & .
  • 30. PhotoMapViewController.h .m PhotoMapViewController.h @interface PhotoMapViewController : UIViewController <MKMapViewDelegate> { ! NSDictionary *photoData; ! MKMapView *mapView; } @property (retain) NSDictionary *photoData; @property (nonatomic, retain) IBOutlet MKMapView *mapView; @end #import "PhotoMapViewController.h" @implementation PhotoMapViewController @synthesize mapView; @synthesize photoData; 0 1 1 111km - (void)viewDidLoad { [super viewDidLoad]; ! mapView.delegate = self; ! } - (void)viewWillAppear:(BOOL)animated { ! CLLocation *location = [photoData valueForKey:@"Location"]; ! MKCoordinateSpan span = MKCoordinateSpanMake(0.1, 0.1); ! MKCoordinateRegion region = MKCoordinateRegionMake(location.coordinate, span); ! [mapView setRegion:region animated:YES]; } - (void)dealloc { ! ! [photoData release]; [mapView release]; setRegion:animated: [super dealloc]; Changes the currently visible region and optionally animates the change. } - (void)setRegion:(MKCoordinateRegion)region animated:(BOOL)animated @end Parameters region The new region to display in the map view. animated Specify YES if you want the map view to animate the transition to the new region or NO if you want the map to center on the specified region immediately
  • 31. PhotoDetailViewController PhotoMapViewController Map . • callback PhotoDetailViewController -goToMapView: . • PhotoMapViewController pushViewController: MapView .
  • 32. -goToMapView: PhotoDetailViewController.m - (IBAction)goToMapView:(id)sender { ! PhotoMapViewController *mapViewController = [[PhotoMapViewController alloc] initWithNibName:@"PhotoMapViewController" bundle:nil]; ! mapViewController.photoData = photoData; ! [self.navigationController pushViewController:mapViewController animated:YES]; ! [mapViewController release]; } UIViewController Class navigationController A parent or ancestor that is a navigation controller. (read-only) @property(nonatomic, readonly, retain) UINavigationController *navigationController Discussion Only returns a navigation controller if the view controller is in its stack. This property is nil if a navigation controller cannot be found.