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];  

    }

  • 相关阅读:
    怎么统计指定文件夹下含有.xml格式的文件数目
    SQLServer触发器创建、删除、修改、查看
    Devexpress 学习不错的网址
    Devexpress
    SQL 查找重复项及批量修改数据成固定格式
    elementui carousel不能自适应问题
    node中console自定义样式
    forEach for for in for of性能问题
    骚东西
    关于arr.map()问题
  • 原文地址:https://www.cnblogs.com/luningning0901/p/4152786.html
Copyright © 2011-2022 走看看