IOS prepareForSegue 多窗口切换学习

源码下载


//查看源文件有3个属性

@property (nonatomicreadonlyNSString *identifier; //标识

@property (nonatomicreadonlyid sourceViewController; //源窗口

@property (nonatomicreadonlyid destinationViewController; //目标窗口

 

/* 默认会生成此方法

#pragma mark - Navigation


// In a storyboard-based application, you will often want to do a little preparation before navigation

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

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/


实现:


/*

 #pragma mark - Navigation

 */

// In a storyboard-based application, you will often want to do a little preparation before navigation

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

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

    NSLog(@"调用B");

    NSDateFormatter *dateformate = [[NSDateFormatter allocinit ];

    [dateformate setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

    NSString *showdate =[dateformate stringFromDate:[NSDate date]];

    //@2调用窗口

    [[segue destinationViewControllersetNumber:showdate];


}


一直在找设置segue标识的方法。

 NSLog(@"%@aaa", [segue identifier]);

打印老是空指针操作,后来通过方法找到需要如下设置:


设置segue的标识 

38650.png

拖一个navigation controller 就可以生成有 navigationbar 的控制了,然后拖动相应的窗口,删除相应的View
804094.png 


595603.png 

最终效果:
180004.png 

24181.png 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值