zoukankan      html  css  js  c++  java
  • 控制器之间的跳转

    1.代码跳转,vc的界面需要写在xib上

    UIViewController *vc = [[UIViewController alloc] init];//普通控制器

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

    2.storyboard按钮跳转,无连线,也可以传值
    - (IBAction)itemClick:(id)sender {
        UIViewController *three = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"three"];
        [self presentViewController:three animated:YES completion:nil];
    }

    3.storyboard直接将第一个控制器按钮拖到第二个控制器 选择show.点击即跳转

    4.storyboard二个控制器相连,有个segue设置Identifier,通过代码跳转:
    [self performSegueWithIdentifier:@"segue" sender:self];
        并且可以通过prepareForSegue:方法传值.
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // segue.identifier:获取连线的ID
        if ([segue.identifier isEqualToString:@"SendValue"]) {
            // segue.destinationViewController:获取连线时所指的界面(VC)
            ReceiveViewController *receive = segue.destinationViewController;
            receive.name = @"Garvey";
            receive.age = 110;
            // 这里不需要指定跳转了,因为在按扭的事件里已经有跳转的代码
            //        [self.navigationController pushViewController:receive animated:YES];
        }
    }

     
  • 相关阅读:
    day59_BOS项目_11
    day58_BOS项目_10
    shell 笔记
    docker + swarm 集群
    HDFS深入浅析
    FTP服务器常规操作
    linux shell 流程控制
    认识黑客常用的入侵方法
    Linux中常用的查看系统信息的命令
    解决Yum安装依赖问题
  • 原文地址:https://www.cnblogs.com/zhongxuan/p/5067269.html
Copyright © 2011-2022 走看看