【发布时间】:2018-01-05 09:05:47
【问题描述】:
如何让 VC 也出现
我试过这个,但 ms 加载干净,没有按钮和 TextView。
let modalViewController = ClipboardViewController()
modalViewController.modalPresentationStyle = .overCurrentContext
present(modalViewController, animated: true, completion: nil)
示例:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if indexPath.row == 0 {
self.navigationController!.pushViewController(self.storyboard!.instantiateViewController(withIdentifier: "ViewController") as UIViewController, animated: true)
} else if indexPath.row == 1 {
// VC with animation
} else if indexPath.row == 2 {
self.navigationController!.pushViewController(self.storyboard!.instantiateViewController(withIdentifier: "Favorite") as UIViewController, animated: true)
} else if indexPath.row == 3 {
self.navigationController!.pushViewController(self.storyboard!.instantiateViewController(withIdentifier: "Settings") as UIViewController, animated: true)
}
}
【问题讨论】:
-
正如您所期待的按钮等,我假设您已经在情节提要或 xib 文件中设置了视图控制器。如果是这种情况,那么您不要使用此行
let modalViewController = ClipboardViewController()创建它,否则您将创建一个没有任何控件设置的程序(如您所见)。您需要从 storyboard/xib 实例化它或创建一个 segue 并执行它。
标签: ios swift xcode modalviewcontroller