Reputation: 435
I'm hoping that i'm simply overlooking something simple. But here the scenario.
I have a root vc that opens a modal view LoginScreen. In that view class I've set up a protocol (ViewControllerDelegate) synthesized, and once a user logs in via the modal, the parent VC closes the modal and all is well.
In LoginScreen.m to close the modal all I have to use is this code:
[self.delegate loginConfirmed:self];
That works perfectly. However, I have another view that gets pushed is login is confirmed. Still as a modal of course. Call it LoginScreen2.
I can't figure out how to get the Modal to close from LoginScreen2 and get back tot he root VC. I've tried a bunch of different variations like this, but no luck.
[((LoginScreen *)self.parentViewController).delegate loginConfirmed:((LoginScreen *)self)];
I've been searching and messing around for a couple hours, with no luck. Again I'm hoping I'm just missing something simple and just not seeing it. If anyone has any ideas that would be awesome.
Upvotes: 0
Views: 210
Reputation: 62676
Not sure who is presenting the second view controller, but one thing that might help you is to know that a modally presented view controller can dismiss itself:
[self dismissModalViewControllerAnimated:YES];
The root view controller can check the user state when it appears, and presentModalViewController:Login1
. Login1 changes the user sign-in state, and dismisses itself. Root sees different user state (when it's about to reappear via the viewWillAppear:
method) and presents modal on Login2
. No delegation needed.
Upvotes: 2