Display and dismiss a modal view controller in Swift

前端 未结 5 1120
栀梦
栀梦 2021-02-04 01:01

When a button is pressed I want to segue between two view controllers by using a Modal Transition style CoverVertical and then dismiss it. There is allot of info ou

相关标签:
5条回答
  • 2021-02-04 01:20

    Its pretty easy :

    to dismiss a modal view with swift 3.0 : Use dismiss Api like below :

    > @IBAction func dismissClick(_ sender: Any) {
    >         dismiss(animated: true, completion: nil)
    >         
    >     }
    

    For present :

    > @IBAction func dismissClick(_ sender: Any) {
    > present(UIViewController(), animated: true, completion: nil)
    >         
    >     }
    

    For more details here you go :

    https://developer.apple.com/documentation/uikit/uiviewcontroller#//apple_ref/doc/uid/TP40006926-CH3-SW96

    0 讨论(0)
  • 2021-02-04 01:21

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

    0 讨论(0)
  • 2021-02-04 01:22

    To Dismiss View Controller in Swift 3.0

    self.dismiss(animated: true, completion: {})
    
    0 讨论(0)
  • 2021-02-04 01:25

    Dismiss view controller in Swift 4:

    dismiss(animated: true, completion: nil)
    
    0 讨论(0)
  • 2021-02-04 01:32

    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)
    
    0 讨论(0)
提交回复
热议问题