Errors while using shouldPerformSegue(withIdentifier, sender) method in swift4

前端 未结 2 440
走了就别回头了
走了就别回头了 2021-01-28 01:12

What I\'m trying to do:

  • checking a condition, if the condition is true, perform segue as normal. If condition is false, call the shouldPerformSegue method and retu
2条回答
  •  温柔的废话
    2021-01-28 02:06

    If you want to perform logic to decide if a segue should be "performed" or not, you need to override shouldPerformSegue. This will allow the OS to (1) kick off things properly and (2) for you to be able to decide if the segue gets done.

    override func shouldPerformSegue(withIdentifier identifier: String, sender: Any?) -> Bool {
        if [criteria met to perform segue] {
            return true
        } else {
            return false
        }
    }
    

提交回复
热议问题