zoukankan      html  css  js  c++  java
  • UIBarButtonItem、UINavigationController

    //在AppDelegate.m中
     
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

        self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
        self.window.backgroundColor = [UIColor redColor];
       
        //创建一个视图控制器(创建之初就加载nib)
        OneViewController *oneVC = [[OneViewController alloc]initWithNibName:@"OneViewController" bundle:nil];
       
        //oneVC控制器的对象放在一个导航控制器的栈底(因为栈内存中只有这一个对象,栈底也就是栈顶,栈顶就是优先显示与窗口之上的对象)
        UINavigationController *navc = [[UINavigationController alloc]initWithRootViewController:oneVC];
    //    [navc pushViewController:oneVC animated:YES];
        //窗口的根视图控制器接收navc(navc的类继承自UIViewController)
        self.window.rootViewController = navc;
       
        //窗口展示在屏幕的最前端
        [self.window makeKeyAndVisible];
        
        return YES;
    }
    /****************************************************************/
    //通过pushViewController方法压栈
        [self.navigationController pushViewController:twoVC animated:YES];
    //出栈的方式:
     
        //直接出栈,一直到栈底(仅剩一个控制器的时候)
        [self.navigationController popToRootViewControllerAnimated:YES];
       
        //指定栈内存中的某个控制器
        [self.navigationController popToViewController:fiveVC animated:YES];
        //一个一个的出栈
        [self.navigationController popViewControllerAnimated:YES];
    /****************************************************************/
    《UIBarButtonItem》:
     
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithTitle:@"返回吗" style:UIBarButtonItemStylePlain target:self action:@selector(doReturn)];
        self.navigationItem.leftBarButtonItem = leftItem;
       
        UIButton *btn = [UIButton buttonWithType:UIButtonTypeContactAdd];
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:btn];
        self.navigationItem.rightBarButtonItem = rightItem;
       
        //显示副标题
        self.navigationItem.prompt = @"hello";
     
  • 相关阅读:
    鸟哥linux——分区命令:split
    鸟哥linux——管线命令
    鸟哥linux——命令执行的判断依据:;,&&,||
    linux:数据流重导向
    Tensorflow计算模型——计算图
    DNS域名解析与本机Host
    相似图片搜索的原理
    谈谈回文子串
    关于字符串精确匹配
    音频采样
  • 原文地址:https://www.cnblogs.com/liuyingjie/p/4989774.html
Copyright © 2011-2022 走看看