storyboard简单使用

//控制页面跳转@“mySegue”,设置storyboard segue的identifier的名称

[self performSegueWithIdentifier:@"mySegue" sender:self];

//控制启动storyboard指向

self.window=[[UIWindowalloc]initWithFrame:[[UIScreenmainScreen]bounds]];

[self.windowmakeKeyAndVisible];

UIStoryboard *rootstory=[UIStoryboardstoryboardWithName:@"login"bundle:nil];

self.window.rootViewController=[_rootstoryinstantiateInitialViewController];

//storyboard之间的跳转

UIStoryboard *stryboard=[UIStoryboardstoryboardWithName:@"qzdlmain"bundle:nil];

[self presentViewController:[stryboard instantiateInitialViewController] animated:YES completion:nil];

//storyboard跳转页面间的传值

在第一个界面对

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender本方法进行重写

例:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    UIViewController *send=[seguedestinationViewController];

   if ([sendrespondsToSelector:@selector(setTitleName:)]) {

    }//需要在Controller中定义,配合以下的一

    if ([segue.identifier isEqualToString:@"SendValue"]) {

ReceiveViewController *receive = segue.destinationViewController;

   receive.name =@"Garvey";

   receive.age = 110;

      }//需要修改segue连线中的Identifier的名字,配合以下的二

}

一、

以上的setTitleName需在第二个页面声明

例:

在.h文件中

@property(weak,nonatomic)id titleName;

在.m文件中

@synthesize titleName;

这便可以了,验证是否有效可以command+左键点击 setTitleName是否有跳转

二、

ReceiveViewController为第二个界面的Controller

例:

在.h文件中

@property (strong, nonatomic) NSString *name;

@property (assign, nonatomic)int age;


StroyBoard跳转以及返回

//根据 segue Identifier跳转界面

[self performSegueWithIdentifier:@"GotoTwo" sender:self];


//modal 方式跳转

[self presentModalViewController:nil animated:YES];


//压进一个viewcontroller

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


//弹出一个viewcontroller  相当与返回上一个界面

[self.navigationController popViewControllerAnimated:YES];


// modal跳转的返回方法

[self dismissModalViewControllerAnimated:YES];





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值