美文网首页
iOS:如何由代码跳转其他storyboard中的VC

iOS:如何由代码跳转其他storyboard中的VC

作者: 少阁主 | 来源:发表于2016-06-01 15:27 被阅读1451次

1:首先,UpgradeHardware.storyboard 是从其他工程中摘进来的,因为需要两个工程进行融合,其他工程中大部分界面都是由storyboard写的,所以,网上找了下,代码调storyboard中的VC方法,下面只是一个极简的总结:

注:主程序代码里之前全是代码写的没有用到sb,现在需要从主程序中的某个页面直接push到次程序拖过来的SB红框中的VC中去。

1:首先:在custom class中,获取到该VC的名字,这里的是DeviceTableViewController

2:在响应事件里写如下代码:

-(void)btnPressed

{

UIStoryboard *UpgradeHardware = [UIStoryboard storyboardWithName:@"UpgradeHardware" bundle:nil];//UpgradeHardware storyboard的名称

UIViewController *firstVC = [UpgradeHardware instantiateViewControllerWithIdentifier:@"DeviceTableViewController”];//跳转VC的名称

[self.navigationController pushViewController:firstVC animated:YES];

}

相关文章

网友评论

      本文标题:iOS:如何由代码跳转其他storyboard中的VC

      本文链接:https://www.haomeiwen.com/subject/buuhdttx.html