在SWIFT中实例化并呈现viewController发行我开始看新的Swift在……上面Xcode 6,我尝试了一些演示项目和教程。现在我被困在:实例化,然后呈现viewController从一个特定的故事板目标-C溶液UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"myStoryboardName" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"myVCID"];
[self presentViewController:vc animated:YES completion:nil];如何在SWIFT上实现这一点?
3 回答
暮色呼如
TA贡献1853条经验 获得超9个赞
let viewController:UIViewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("ViewController") as UIViewControllerself.presentViewController(viewController, animated: false, completion: nil)
UIViewController *viewController = [[UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil] instantiateViewControllerWithIdentifier:@" ViewController"];
/* Helper to Switch the View based on StoryBoard @param StoryBoard ID as String */func switchToViewController(identifier: String) { let viewController = self.storyboard?.instantiateViewControllerWithIdentifier(identifier) as! UIViewController self.navigationController?.setViewControllers([viewController], animated: false)}
- 3 回答
- 0 关注
- 1173 浏览
添加回答
举报
0/150
提交
取消