zoukankan      html  css  js  c++  java
  • push 和 pop 以及模态

    1.首先UINavigationcontroller 得持有controller

    例如 

       RootViewController *rootVC=[[RootViewController alloc]init];

       UINavigationController *rootNC=[[UINavigationController alloc]initWithRootViewController:rootVC];

        self.window.rootViewController=rootNC;

    2.push哪个controller就把哪个controller引入,在点击事件里初始化,

    例如

    -(void)ItemCount:(UIBarButtonItem *)sender

    {

        FirstViewController *fies=[[FirstViewController alloc]init];

        [self.navigationController pushViewController:fies animated:YES];

    }

     3.返回即pop  首先设置

    self.navigationItem.title=@"根视图";

        UIBarButtonItem *b1=[[UIBarButtonItem alloc]initWithTitle:@"下一张" style:UIBarButtonItemStyleDone target:self action:@selector(ItemCount:)];

        self.navigationItem.rightBarButtonItem=b1;

      然后在barbutton事件里实现pop的功能

    -(void)ItemCount:(UIBarButtonItem *)sender

    {

        [self.navigationController popToRootViewControllerAnimated:YES];

    }

    4.模态

    push的时候一样 

    -(void)button2Action:(UIButton *)sender

    {

    GreenViewController *green=[[GreenViewController alloc]init];

    //模态视图  临时弹出

        [self presentViewController:green animated:YES completion:nil];

    }

    一,设置一个button  有点击事件( 不用navigationcontroller持有,)

    二,事件里退回模态就OK了

    -(void)buttonAction:(UIButton *)sender

    {

        //退出模态

        [self dismissViewControllerAnimated:YES completion:nil];  

    }

  • 相关阅读:
    疫情控制
    数据结构1
    NOIP 模拟 921
    ml-agents项目实践(一)
    Appium的安装及简单的使用介绍
    移动设备管理平台的搭建(基于STF/ATXServer2)
    ClickHouse利器—如何提高留存计算速度
    Linux基本操作命令
    深度学习与强化学习的两大联姻:DQN与DDPG的对比分析
    漏洞扫描软件AWVS的介绍和使用
  • 原文地址:https://www.cnblogs.com/luningning0901/p/4152786.html
Copyright © 2011-2022 走看看