当一个按钮被按下时,我想通过使用Modal转换样式CoverVertical在两个视图控制器之间进行分离,然后将其关闭。在目标C中有很多关于如何做的信息,但是在Swift中找不到任何好的信息。到目前为止,我已经这样做了,但我不认为这是正确的:
@IBAction func insertStatus(sender: UIButton) {
var StatusVC: StatusViewController = StatusViewController()
var modalStyle: UIModalTransitionStyle = UIModalTransitionStyle.CoverVertical
StatusVC.modalTransitionStyle = modalStyle
self.presentViewController(StatusVC, animated: true, completion: nil)
}我使用的“解雇”也是不起作用的:
@IBAction func statusSaved(sender: UIBarButtonItem) {
self.dismissViewControllerAnimated(false, completion: { () -> Void in
let usersVC: UsersViewController = self.storyboard?.instantiateViewControllerWithIdentifier("UsersViewController") as UsersViewController
})
}发布于 2015-01-25 18:31:37
Swift 5:
present(UIViewController(), animated: true, completion: nil)
dismiss(animated: true, completion: nil)Swift 2.2:
self.presentViewController(true, completion: nil)隐藏/解散视图控制器:
self.dismissViewControllerAnimated(true, completion: nil)发布于 2016-10-23 16:13:19
在Swift 3.0中取消视图控制器
self.dismiss(animated: true, completion: {})发布于 2015-01-25 18:14:43
您可以从presentViewController:animated:completion:中使用UIViewController和dismissViewControllerAnimated:completion:方法。见docs 这里
https://stackoverflow.com/questions/28139547
复制相似问题