I have in my objective-c application a loginViewController from where I display the homeViewController after the user logged in successfully. This is how I display the home:
-(void) displayHome {
UIViewController * home = [self.mainStoryboard instantiateViewControllerWithIdentifier:@"homeViewController"];
_window.rootViewController = publicHome;
[_window makeKeyAndVisible];
}
The displayHome
function is in the AppDelegate
. After that, in the homeViewController i present some view controllers using
[self presentViewController:controller animated:false completion:nil];
Sometimes I have to redirect the user to the loginViewController so I call this VC the same as I do for the home (by setting the rootViewController) in order to remove all the other views. But when I use the 3d debugger I see that the presented views are there.
Why when I set the rootViewController
with the loginViewController
, the presented views are not removed even if there are attached to the homeViewController
that is as the rootViewController
?
Edit
An example:
Suppose that from the homeViewController
(that is the rootViewController
) I go to the viewController1
(viewController1
is presented). Now when I press a button in the viewController1
I have to return to the loginViewController
. In the button action, this is what I do:
I call
[self dismissViewControllerAnimated:false completion:nil];
and [appDelegate displayLogin];
//AppDelegate
-(void) displayLogin {
UIViewController * login = [self.mainStoryboard instantiateViewControllerWithIdentifier:@"homeViewController"];
_window.rootViewController = publicHome;
[_window makeKeyAndVisible];
}
When I debug, I find that the viewController1
is still here. It under the login. Why is the viewController1
here even if I set the rootViewController
?