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";
     
  • 相关阅读:
    PHP常量
    jquery中的几种常用总结
    jquery中的ajax
    常用的jquery一些总结
    js验证手机号邮箱号用户名
    PHP优化杂烩
    一个php开发的用于路由器的小功能
    HTML <form>
    window.open
    try&catch
  • 原文地址:https://www.cnblogs.com/liuyingjie/p/4989774.html
Copyright © 2011-2022 走看看