Ios 模式VC未打开(Swift)
如何使VC也出现 我试过了,但ms加载干净,没有按钮和文本视图Ios 模式VC未打开(Swift),ios,swift,xcode,modalviewcontroller,Ios,Swift,Xcode,Modalviewcontroller,如何使VC也出现 我试过了,但ms加载干净,没有按钮和文本视图 let modalViewController = ClipboardViewController() modalViewController.modalPresentationStyle = .overCurrentContext present(modalViewController, animated: true, completion: nil) 示例: 正如您所期望的按钮等,我假设您已经在序列图像板或xib文件中设置了
let modalViewController = ClipboardViewController()
modalViewController.modalPresentationStyle = .overCurrentContext
present(modalViewController, animated: true, completion: nil)
示例:
正如您所期望的按钮等,我假设您已经在序列图像板或xib文件中设置了视图控制器。如果是这种情况,则不使用以下行创建它
让modalViewController=ClipboardViewController()
,否则将在不设置任何控件的情况下创建一个控件(如您所见)。您需要从故事板/xib中实例化它,或者创建一个序列并执行该操作。
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)
}
}
let modalViewController = self.storyboard?.instantiateViewController(withIdentifier: "ClipboardViewController ID") as? ClipboardViewController
modalViewController?.modalPresentationStyle = .overCurrentContext
self.present(modalViewController!, animated: true, completion: nil)