IOS prepareForSegue 多窗口切换学习

来源:互联网 发布:淘宝店铺加盟骗局 编辑:程序博客网 时间:2024/05/16 04:34

源码下载


//查看源文件有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 


0 0
原创粉丝点击