zoukankan      html  css  js  c++  java
  • 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.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  • 相关阅读:
    消息分发
    subprocess.CalledProcessError: Command ‘(‘lsb_release’, ‘-a’)’ returned non-zero exit status 1.
    ubuntu14.04 安装python3.7
    通过shell脚本查看python版本并比较
    shell 小数比较大小
    python 私有方法
    python 类的倒入
    python 路径拼接
    python 脚本接受参数
    python 获取文件运行路径
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3164312.html
Copyright © 2011-2022 走看看