您的位置:首页 > 编程语言

storyboard用代码跳转的几种方法

2014-08-15 12:38 337 查看
http://www.cnblogs.com/zhangdadi/archive/2012/12/03/2799816.html

第一种:给segue标记个Identifier再用代码触发,要点:segue开始的那边都连在View界面上,不上连上button上,要不点到就会跳转,如下:

再用代码这样触发这个跳转的segue,如:

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


第二种:能过取得storyboard文件里的viewController再用常规方法跳转,先设置storyboard里viewController的标志Storyboard ID,如下:

再用代码这样跳转:

//    UIStoryboard *board = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *next = [[self storyboard] instantiateViewControllerWithIdentifier:@"IconView"];
[self presentModalViewController:next animated:NO];


注解的代码等同于[self storyboard] ,不过[self storyboard]是官方写好的sdk,如果你的Storyboard文件名字修改过就用上面的代码自己加载.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: