I am using QuickDialog to push a login form. Everything is working except the view controller can not be dismissed. The code like this:
- (void)onLogin:(QButtonElement *)buttonElement
{
[self loading:YES];
Info *info = [[Info alloc] init];
[self.root fetchValueUsingBindingsIntoObject:info];
[self.client loginWithUsername:info.login password:info.password onSuccess:^(NSDictionary *result) {
NSLog(@"user signed in");
[self loading:NO];
[self dismissViewControllerAnimated:YES completion:nil];
} onFailure:^(NSError *error) {
NSLog(@"login error");
}];
}
And I am using these codes to push this view controller
QRootElement *root = [[QRootElement alloc] initWithJSONFile:@"loginform"];
LoginController *loginController = (LoginController *)[QuickDialogController controllerForRoot:root];
[self.navigationController pushViewController:loginController animated:YES];
I'm tempted to tell you to do this:
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
Here's Apple's documentation:
The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, however, it automatically forwards the message to the presenting view controller.
I'm not sure why your call isn't "forwarding" and closing anyway. Perhaps you presented using presentModalViewController
? If that's the case, balance with dismissModalViewControllerAnimated
and that may fix.
Of course we're all assuming the the rest of your code is correct and that you are in fact seeing NSLog(@"user signed in");
print when you sign in.
Good luck!
>> UPDATE <<
Wow, sorry. I just noticed you wrote "QuickDialog to push a login form" and see you added an example of how you present this screen. Since you are pushing this onto the nav controller stack, you need to pop it off. This will fix things:
[self.navigationController popViewControllerAnimated:YES];
Enjoy.