1

side menu

I calling the login segue to another view controller (login view) like this , I have to set it my login view as front view controller when prepareForSegue or else i dont know why my side menu will be keep stick in the front view, which my login view will not be fully display:

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showSegue" {

        self.revealViewController().revealToggleAnimated(false)
        let vc = storyboard!.instantiateViewControllerWithIdentifier("LoginViewController")as! LoginViewController
        self.revealViewController().setFrontViewController(vc, animated: false)

    }
}

And after user have successfully login in the login view, it should be popup a alert view notice the user have success login and back to the previous page, and i using unwind segue:

let message = (MCLocalization.sharedInstance.stringForKey("login_success_message",  replacements: ["%s" : fullName]))
                    let alert = UIAlertController(title: (MCLocalization.sharedInstance.stringForKey("login_success_title")), message: message, preferredStyle: UIAlertControllerStyle.Alert)

                    let OKAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {
                        (_)in
                        self.performSegueWithIdentifier("unwindSideMenu", sender: self)
                    })

                    alert.addAction(OKAction)
                    self.presentViewController(alert, animated: false, completion: nil)

But the unwind segue its not working, it come out this error:

2016-07-20 10:44:47.945 Jocom[9475:501947] Unbalanced calls to begin/end appearance transitions for <Jocom.LoginViewController: 0x7fbad2817630>.

How should i solve this problem?

minimomo
  • 581
  • 1
  • 6
  • 16
  • do you already add action segue when perform unwind segue – Phu Duy Jul 20 '16 at 03:02
  • yes, i done it already. – minimomo Jul 20 '16 at 03:05
  • what do you do with unwind segue, i think it's not necessary – Phu Duy Jul 20 '16 at 03:10
  • because after user have successfully login, i want to unwind segue to the previous page to set the login button hidden since user have successful login. Which the unwindToMenu is look like this: @IBAction func unwindToMenu(segue: UIStoryboardSegue) { self.logInBtn.hidden = true self.logOutBtn.hidden = false } – minimomo Jul 20 '16 at 03:14
  • or do you have any else way or idea to do it? – minimomo Jul 20 '16 at 03:15
  • `unwindSideMenu ` or `unwindToMenu ` – Phu Duy Jul 20 '16 at 03:17
  • sorry, it is unwindSideMenu: @IBAction func unwindSideMenu(segue: UIStoryboardSegue) { self.logInBtn.hidden = true self.logOutBtn.hidden = false } – minimomo Jul 20 '16 at 03:20
  • Your prepare method is completely wrong. When prepareForSegue is called you will have segue.destinationViewController as an ALREADY CREATED view controller. You simply grab that, case it to the type of view controller it is, and then set properties on it. You should not be creating or presenting it yourself. – Gargoyle Jul 20 '16 at 03:31
  • Can you show me how pls? @Gargoyle – minimomo Jul 20 '16 at 03:34
  • i have to set it my login view as front view controller when prepareForSegue or else i dont know why my side menu will be keep stick in the front view, which my login view will not be fully display. i edited my question, pls have a look at the screenshot @Gargoyle – minimomo Jul 20 '16 at 03:43
  • http://stackoverflow.com/questions/28455517/swift-unbalanced-calls-to-begin-end-appearance-transitions-for-uinavigationcont – Adrian Jul 20 '16 at 03:47
  • @Adriani didnt call my function at viewdidload – minimomo Jul 20 '16 at 03:52

0 Answers0