0

I am going to try my best to explain what is happening, but please let me know if I can clarify further. I naturally have multiple view controllers and between them, I use segues to transition and transfer. Below is the order of the views I am having an issue with:

  • Edit Profile View; Select to See Current Address
  • Current Address View shows. This view has back button (pops the view from stack)
  • Back at Edit Profile View, I select to Update Current Address
  • I select to save address and notified via UIAlert that save successful (reflected in backend). I click OK in UIAlert related to the following action:

    let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default){
    UIAlertAction inself.basicMap.removeObserver(self, forKeyPath: "myLocation")
    self.performSegueWithIdentifier("backToEditFromWorkSegue", sender: self)}`
    

then I go back automatically to Edit Profile. If I click the Done button in Edit Profile view, the view disappears but the Update Current Address shows again. This is what I want to know why is happening and how can it be solved. The Done button on the Edit Profile is linked to this:

self.customNavigationBar.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Done, target: self, action: "addTapped")

and addTapped is:

func addTapped()
{
    self.navigationController?.popViewControllerAnimated(true)
}

From what I can think about here, I believe something is going wrong with popping out the views.

Peter Todd
  • 8,561
  • 3
  • 32
  • 38
ksa_coder
  • 1,393
  • 3
  • 15
  • 38

1 Answers1

1

Your code will pop the current view controller off the stack and show you the previous view controller. I think you are trying to get back to the root view controller? If so try:

self.navigationController?.popToRootViewControllerAnimated(true)
Peter Todd
  • 8,561
  • 3
  • 32
  • 38