Display and dismiss a modal view controller in Swift Display and dismiss a modal view controller in Swift ios ios

Display and dismiss a modal view controller in Swift


Swift 5:

present(UIViewController(), animated: true, completion: nil)dismiss(animated: true, completion: nil)

Swift 2.2:

self.presentViewController(true, completion: nil)

Hide/dismiss a view controller:

self.dismissViewControllerAnimated(true, completion: nil)


To Dismiss View Controller in Swift 3.0

self.dismiss(animated: true, completion: {})


You can use presentViewController:animated:completion: and dismissViewControllerAnimated:completion: methods from UIViewController. See docs here


matomo