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

     
  • 相关阅读:
    电商-订单设计(2)
    学生-课程-成绩-教师表的设计
    电商-订单设计(1)
    WCF-错误集合002
    调用 WebService 请求因 HTTP 状态 407 失败
    SQLSERVER 中的事务嵌套
    sqlserver 中的异常捕获
    c# 和 sqlserver 中的事务
    ADO_NET 数据库连接字符串大全
    break循环和continue循环
  • 原文地址:https://www.cnblogs.com/zhongxuan/p/5067269.html
Copyright © 2011-2022 走看看