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];
  • 相关阅读:
    HTML 简介
    Composer 安装与使用
    给手绘图着色(添加颜色或色彩):CVPR2020论文点评
    图像分类:CVPR2020论文解读
    CVPR2020论文解读:OCR场景文本识别
    CVPR2020论文解读:手绘草图卷积网络语义分割
    汽车芯片综述
    CVPR2020论文解析:视觉算法加速
    CVPR2020无人驾驶论文摘要
    CVPR2020论文解析:视频语义检索
  • 原文地址:https://www.cnblogs.com/buro79xxd/p/4298958.html
Copyright © 2011-2022 走看看