storyBoard之初学习

接触到一个项目,用到了storyBoard,虽然在4.2就有了,可是一直没用过,今天从网上找了些资料学习了一下啊,在这里记录一下。

一片很好的博客,写的非常好,地址 http://wangjun.easymorse.com/?p=1564

要明确几个问题:
1.  .h .m .xib不再是传统的一块建立,其分为了
     a) 在storyBoard中拖入xxxViewController
     b) 建立不带xib的 xxx.h  xxx.m
     c) 将xxxViewController 的class指定为 xxx

2.  segue指的是 在storyBoard中 灰色的箭头
     包括:Push, Modal, Popover and more

3.  用来传值的特定方法 假设由  A.  --aSegue-->  B. 
     注:一个identifier=“aSegue”的segue
     在A.m中 用以下方法调用segue进行跳转
    
[self performSegueWithIdentifier:@"aSegue" sender:self];
     

然后
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
    NSLog(@"%@",segue.destinationViewController);  //就是B.
    NSLog(@"%@",[sender class]);         //就是A
    NSLog(@"%@",[segue identifier]);    //就是"aSegue"

    //传值操作
    A *a = (A *)sender;
    B *b = (B *)segue.destinationViewController;
    b.param1 = a.param1;
    b.param2 = a.param2;
    //... 
}
 

猜你喜欢

转载自shuixian361.iteye.com/blog/1730644