storyboard学习心得

来源:互联网 发布:linux ddos攻击脚本 编辑:程序博客网 时间:2024/06/06 04:58
1.Is Initial View Controller可以设置window的根控制器

2.获取storyBoard上的视图控制器
先获取storyBoard 然后获取上面的VC
UIStoryboard*storyBoard = [UIStoryboardstoryboardWithName:@"SB2"bundle:[NSBundlemainBundle]];//得到SB2上的视图控制器
UIViewController*VC = [storyBoardinstantiateViewControllerWithIdentifier:kSB2];
    [selfpresentViewController:VCanimated:YEScompletion:nil];

3.用self加载storyBoard上的视图控制器
//如果加载的控制器和当前控制器在一个storyBoard 里面,并且此storyBoard在之前已经加载过,那就可以使用下面此种方式加载视图控制器;
UIViewController  *VC = [self.storyboardinstantiateViewControllerWithIdentifier:@"KDetailSB"];

4.先加载这个方法(加载中间的连线)然后才会加载下一个视图控制器 可以在此方法中配置下一视图控制器的属性
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender {
UIViewController*VC = segue.destinationViewController;
//在下一个控制器将要加载的时候,可以在此方法中配置属性 比如添加子视图等
VC.
hidesBottomBarWhenPushed= YES;
}

5.storyBoard中两个视图控制器进行传值 利用加载两个视图控制器要先加载中间连线的性质
- (IBAction)unwindForSegue:(UIStoryboardSegue*)unwindSegue towardsViewController:(UIViewController*)subsequentVC {
SecondViewController*secondVC = unwindSegue.sourceViewController;//这里返回的时候变成了开始的控制器
   self.showLabel.text= secondVC.myTF.text;
}

6.可以在storyBoard中修改约束的值 也可以在代码中修改
self.heightConstant.constant= 0;

7.如果push的ViewController来自于storyBoard  要通过storyBoard 获取
ChatViewController*chatVC = [self.storyboardinstantiateViewControllerWithIdentifier:kChatVCID];
[self.navigationControllerpushViewController:chatVCanimated:YES];

8.用storyboard拖的collectionView使用带注册的方法不需要再写注册方法 xib的话就要
//用的storyboard拖的前面不需要注册
UICollectionViewCell*cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"myCell"forIndexPath:indexPath];







0 0
原创粉丝点击