0

For my iOS application, I have a login screen and a register screen, each with their own UIViewController (LoginController and RegisterController respectively). On the register screen, I have added a back button that performs a segue to the login screen.

When I click the back button, the implementation file seems to change (from RegisterController.m to LoginController.m), but the actual screen does not change. I have added the code NSLog(@"In LoginController"); at the top of my LoginController.m file (after [super viewDidLoad];), and when I click the back button on the register screen, my log prints "In LoginController" every time I click the back button, but the screen never changes.

I created the segue similarly to other segues in my application that work correctly. I used the storyboard, held control on the button and dragged the segue to the LoginController.

Does anyone know why this is happening?

EDIT: So I have changed my segues to unwind segues, so that I can get back to the original view of the navigation controller. I have an unwind segue from LoginController to TutorialController, but when I try to unwind from RegisterController to LoginController, the view does not change (but the unwind method in LoginController is called).

moneymango
  • 71
  • 5
  • Are you using Navigation Controller to switch between this two screens? If you want a back button it should be pop/push segues. – Tomasz Bąk Aug 14 '14 at 18:47
  • Yes I am using a Navigation Controller with a push segue – moneymango Aug 14 '14 at 19:22
  • You shouldn't use anything other than an unwind segue to go back to a previous controller, if you're using segues. I don't know why what you're doing would cause the screen to not change though. – rdelmar Aug 14 '14 at 20:02
  • @rdelmar I am using an unwind segue, and I have created it based off of the answer given [here](http://stackoverflow.com/questions/12561735/what-are-unwind-segues-for-and-how-do-you-use-them). I get into the unwind method in LoginController, but the view doesn't change. – moneymango Aug 14 '14 at 21:30
  • It's hard to tell what's going on, but if your log of "LoginController" is in the viewDidLoad method of that controller, it shouldn't be called when coming back to that controller via an unwind segue -- it should go back to the same instance that already exists, so viewDidLoad shouldn't be called again. IT might help if you could post an image of your storyboard somewhere. – rdelmar Aug 14 '14 at 22:13
  • @rdelmar Sorry, before I was using a push segue to go back from RegisterController to LoginController, and was taken into viewDidLoad. Now I am using an unwind segue and I'm taking into my unwind segue method `(IBAction)unwindToLogin:(UIStoryboardSegue *)unwindSegue`. I am getting into the unwind method but the view does not change. – moneymango Aug 14 '14 at 23:16

1 Answers1

0

So I figured out the problem.

In performSegueWithIdentifier, I had sender:self instead of sender:self.backBtn

moneymango
  • 71
  • 5