zoukankan      html  css  js  c++  java
  • 导航视图(四)

    导航视图

    1、创建导航视图根视图:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        
        self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
        
        ViewController* viewController = [[ViewController alloc]
                                              initWithNibName:@"ViewController" bundle:nil];
        
        self.navigationController = [[UINavigationController alloc]
                                     initWithRootViewController:viewController];
        
        self.window.rootViewController = self.navigationController;
        [self.window makeKeyAndVisible];
        
        return YES;
    }

    2、跳转到新视图控制器:

    SecondViewController* secondView = [[SecondViewController alloc]
                                          initWithNibName:@"SecondViewController" bundle:nil];
        
        [self.navigationController pushViewController:secondView animated:nil];

    3、返回之前的视图控制器:

        //回到上一级视图
    //    [self.navigationController popViewControllerAnimated:YES];
        
        //回到根视图
    //    [self.navigationController popToRootViewControllerAnimated:YES];
        
        //回到指定视图
        NSArray * ctrlArray = self.navigationController.viewControllers;
        [self.navigationController popToViewController:[ctrlArray objectAtIndex:0] animated:YES];

    备注:这里各个压入堆栈中的ViewController 都采用self.navigationController获取导航控制器。可参考下文:

    http://kingbinchow.iteye.com/blog/1990807

  • 相关阅读:
    2021.5.10-(叶子相似的树)
    2021.5.8-N皇后(回溯)
    2021.5.6-(雪糕最大数)
    2021.4.23刷题(回溯-全排列)
    可持久化动态图上树状数组维护01背包
    Infinite String Comparision
    第6章 操作系统 存储器管理(二)
    markdown
    操作系统 第6章 存储管理(一)
    操作系统 第五章 死锁 (二)
  • 原文地址:https://www.cnblogs.com/Fredric-2013/p/5966707.html
Copyright © 2011-2022 走看看