zoukankan      html  css  js  c++  java
  • UINavigation,UiView,ModalView Controller之间的关系

    如果当前是个VC,那么就太简单了,直接就可以push到下一个vc
    AddShopViewController *controller = [[AddShopViewController alloc] init];
    controller.view.backgroundColor = [UIColor whiteColor];// 设置背景色为白色,消除残影
    [self.navigationController pushViewController:controller animated:YES];
    有时候需要从modal view里pushviewcontroller,这当然是不行的,因为你没有NC,可以NSLog一下试试就知道了。
    NSLog(@"ViewControllers before pushing: %@", self.navigationController.viewControllers);
    这时你要加某个viewController的view在你的self.view上,你必须做的是:[self addChildViewController:xxx];或者addSubview。因为没有nav,如果想用nav来控制vc,一般是先有nav,然后把vc加入nav中,如果本身就是个vc那么直接
    UINavigationController *navController = [[UINavigationController alloc]initWithRootViewController:self];
    [self presentViewController:navController animated:YES completion:nil];
    这样你的modal就有一个nv,那么你就可以在这个modal里边用[self.navigationController pushViewController:controller animated:YES];
    完整的一个写法是这样的,Storyboard表述的很清楚
    MyViewController *myViewController = [MyViewController alloc] init];
    UINavigationController *navController = [UINavigationController alloc] initWithRootViewController:myViewController];
    // Presuming a view controller is asking for the modal transition in the first place.
    [self presentViewController:navController animated:YES completion:nil];
  • 相关阅读:
    蓝桥杯省赛经验
    阅读笔记四
    阅读笔记二
    阅读笔记一
    动态规划——Maximum Sum of 3 Non-Overlapping Subarrays
    动态规划——Remove Boxes
    动态规划——Dungeon Game
    动态规划——Freedom Trail
    动态规划——Frog Jump
    《软件需求十步走》阅读笔记一
  • 原文地址:https://www.cnblogs.com/buro79xxd/p/4298958.html
Copyright © 2011-2022 走看看