What is the proper way to dismiss a modal when using storyboards?

前端 未结 6 1040
终归单人心
终归单人心 2021-02-05 00:24

Using storyboards, what is the proper way to dismiss a modal?

  • using IBAction and writing code to dismiss after a button click?
  • using segue and notify the
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-05 00:44

    According Alex Cio answer for Swift 3 and XCode 8.3:

    Create class:

    import UIKit
    
    class DismissSegue: UIStoryboardSegue {
        override func perform() {
            self.source.presentingViewController?.dismiss(animated: true, completion: nil)
       }
    }
    

    But in storyboard you should choose:

    Action Segue -> Custom -> dismiss

    Only after this option appear on Action Segue menu

提交回复
热议问题