I have a splitviewcontroller that would call a loginview controller if there’s a need for a login. This is how I would call the modal view
if([[NSUserDefaults standardUserDefaults] objectForKey:@"username"] == nil){
[self performSegueWithIdentifier:@"LoginSegue" sender:self];
}
This is how my storyboard looks like:
--- uinavigation
- masterview |
uispliviewcontroller
- detailview |
--- main dashboard view -(LoginSegue)--loginviewcontroller
|
|------ another viewcontroller
now I can get to the loginview without a problem and then I would try to dismiss the modal so it can go back to the maindashboard view using this
if([[NSUserDefaults standardUserDefaults] objectForKey:@"username"] != nil){
[self dismissViewControllerAnimated:YES completion:nil];
}
but it wouldn’t do anything.
Was wondering how I can properly dismiss that modal view that was called after login?
Any advice is very much appreciated.
Thanks!!!
For a login, a modal presentation might make more sense. Rather than connecting it with a segue, give the LoginViewController a Storyboard ID, like “LoginViewController”. (delete the segue to it, select the login vc in storyboard and find the storyboard id field in the identity inspector).
Then, instead of
performSegue, do this …Having done this, the dismiss will function as you expect it to.