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

    }

  • 相关阅读:
    Compile Groovy/Spock with GMavenPlus
    Jenkins Slave Nodes – using the Swarm Plugin
    [NodeJS]Jenkins-cli
    [CoffeeScript]使用Yield功能
    [JavaScript]String.format
    [CoffeeScript]在WebStorm里运行CoffeeScript
    自动化运维的三阶段理论
    [Ruby]Unzipping a file using rubyzip
    测试文章引用
    敏捷软件测试读书笔记
  • 原文地址:https://www.cnblogs.com/luningning0901/p/4152786.html
Copyright © 2011-2022 走看看