Using shouldPerformSegueWithIdentifier( ) method in Swift

前端 未结 2 1438
日久生厌
日久生厌 2020-12-11 07:52

I am trying to use swift\'s shouldPerformSegueWithIdentifier() method, but it accepts 2 arguments. These are (identifier: String!, sender:AnyObject)

My main goal is

2条回答
  •  囚心锁ツ
    2020-12-11 08:17

    isn't it what you want to do?

    override func shouldPerformSegueWithIdentifier(identifier: String!, sender: AnyObject!) -> Bool {
        if identifier == "LoginSuccessSegue" { // you define it in the storyboard (click on the segue, then Attributes' inspector > Identifier
    
            var segueShouldOccur = /** do whatever you need to set this var to true or false */
    
            if !segueShouldOccur {
                println("*** NOPE, segue wont occur")
                return false
            }
            else {
                println("*** YEP, segue will occur")
            }
        }
    
        // by default, transition
        return true
    }
    

提交回复
热议问题