• IOS开发之UI设计---导航控制器(UINavigationController)


    IOS UI之导航控制器 

    UINavigationController : UIViewController

    UINavigationController 用于管理UIViewCotroller

    UINavigationController toolbar + custom content + bar三部分组成, 以栈的形式管理UIViewController,栈底必须有一个UIViewController,称为基栈.

    Navigation view由下面三部分组成:

    Navigation bar(top) / Custom content(controller.view,bosom) / Navigation toolbar(buttom)

     

    AppDelegate:

    //关联UIWindow 自定义UIViewController UINavigationController

    RootViewController *rootCtrl = [[RootViewControlleralloc]init]; 

        //实例化一个UINavigationController,并设置一个基栈(UIViewController)

        UINavigationController *navCtrl = [[UINavigationControlleralloc]initWithRootViewController:rootCtrl];

        //navCtrl作为UIView的根视图控制器

        self.window.rootViewController = navCtrl;

        [navCtrl release];

        [rootCtrl release];

     

    RootViewController:loadView()

     

    self.navigationController.toolbarHidden = NO;//设置toolbar显示隐藏属性

        self.title = @"beauty”;//设置导航栏标题

     

    viewWillAppear:(BOOL)animated:

    self.navigationController.navigationBar 

    - (void)setBackgroundImage:image forBarMetrics:barMetrics //设置NavigationBar背景图片

     

    bar.height  44px

    toolbar.height  44px

     

    UIButton点击事件中:(UINavigationController以栈的方式管理UIViewController)

    - (UIViewController *)popViewControllerAnimated:(BOOL)animated; // Returns the popped controller.

    - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; // Pops view controllers until the one specified is on top. Returns the popped controllers.

    - (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; // Pops until there's only a single view controller left on the stack. Returns the popped controllers.  返回第一层UIViewController

     

     

    导航栏跳转到视图控制器

    //实例化要跳转过去的UIViewController

        MyUIViewController *myCtrl = [[MyUIViewControlleralloc]init];

        //基栈访问导航 : self.navigationController

        [self.navigationControllerpushViewController:myCtrl animated:YES];//采用push的方式入栈,入栈后,系统会自动给新的UIViewController加上返回前一个UIViewControllerNavigation Bar,bar的标题是前一个bar的标题,

        [myCtrl release];

     

    - (void)viewWillAppear:(BOOL)animated{

        //设置导航栏背景图片

        [self.navigationController.navigationBarsetBackgroundImage:[UIImageimageNamed:@"1.png"] forBarMetrics:0];

         self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    }

     

     

    /*

      The next two methods are replacements for presentModalViewController:animated and

      dismissModalViewControllerAnimated: The completion handler, if provided, will be invoked after the presented

      controllers viewDidAppear: callback is invoked.

    */

    - (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion NS_AVAILABLE_IOS(5_0);

    // The completion handler, if provided, will be invoked after the dismissed controller's viewDidDisappear: callback is invoked.

    - (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion NS_AVAILABLE_IOS(5_0);

     

    //-----------------------------------------------------------

    UINavigationController:The UINavigationController class implements a specialized view controller that manages the navigation of hierarchical content. This navigation interface makes it possible to present your data efficiently and also makes it easier for the user to navigate that content. This class is generally used as-is but may be subclassed in iOS 6 and later.

    UITool Bar + Custom content + UINavigationBar

    UIViewController: UINavigationController栈的形式管理UIViewController(必须要有一个基栈)

    UIBarButtonItem:A bar button item is a button specialized for placement on a UIToolbar or UINavigationBar object. It inherits basic button behavior from its abstract superclass, UIBarItem. The UIBarButtonItem defines additional initialization methods and properties for use on toolbars and navigation bars.

    导航栏按钮的类,不是UIButton.

    UINavigationItem:The UINavigationItem class encapsulates information about a navigation item pushed on a UINavigationBar object’s stack. A navigation bar is a control used to navigate hierarchical content. A UINavigationItem specifies what is displayed on the navigation bar when it is the top item and also how it is represented when it is the back item.

    管理UINavigationBar,包含 backBarButtonItem(系统自带的返回按钮) + leftBarButtonItem +rightBarButtonItem + title + titleView(当前UIViewController)  设置方法是-(void)navigationItem.

     

    UINavigationBar:The UINavigationBar class implements a control for navigating hierarchical content. It’s a bar, typically displayed at the top of the screen, containing buttons for navigating up and down a hierarchy. The primary properties are a left (back) button, a center title, and an optional right button. You can specify custom views for each of these.

    -(void)navigationItem,由每一个UIViewController定制,只有一个,多次复用.

    UIToolbar:A toolbar is a control that displays one or more buttons, called toolbar items. A toolbar momentarily highlights or does not change the appearance of an item when tapped.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    打印沙漏
    秋季学期学习总结
    反射
    线程(二)join、yeild、同步(synchronized:同步块,同步方法;,Lock)、非线程安全单例模式、线程安全单例模式、多线程售卖电影票处理、通过线程依次打印A、B、C、wait和sleep
    线程(一)
    红包计算的方法(通过2倍指数法进行计算,通过线性切割法计算)
    Math常用类、Date类、Calendar类、两者相互转换
    Java包(访问修饰符的范围)、String字符串、StringBuilder类、基本类型和引用类型
    编写一个系统(登录、注册、验证用户名密码和验证码、覆盖存储用户)
    递归的使用:调用方法自身
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3164312.html
Copyright © 2020-2023  润新知