在objective-C中,为了从不同的故事板移动另一个视图控制器,我们将使用以下编码来实现我们想要的。
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Customer" bundle:nil];
HomeSummaryViewController *creaccVC = [storyboard instantiateViewControllerWithIdentifier:@"HomeSummaryViewController"];
[self.navigationController pushViewController:creaccVC animated:YES];
在swift版本中,请帮助我如何像Objective-C一样做什么?
答案 0 :(得分:5)
它几乎与Objective-C版本相同。
let storyboard = UIStoryboard(name: "Customer", bundle: nil)
let vc = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController")
self.navigationController?.pushViewController(vc, animated: true)
答案 1 :(得分:0)
Swift中的上述代码如下所示:
let storyboard: UIStoryboard = UIStoryboard(name: "Customer", bundle: nil)
let homeView: HomeSummaryViewController = storyboard.instantiateViewControllerWithIdentifier("HomeSummaryViewController") as! HomeSummaryViewController
self.navigationController?.pushViewController(homeView, animated: true)