How to add a Cancel button on the WebView that doesn't prematurely closes the view

120 views
Skip to first unread message

Aziz Light

unread,
Mar 31, 2013, 5:22:33 PM3/31/13
to gtm-o...@googlegroups.com
Hi everybody,

I subclassed GTMOAuth2ViewControllerTouch to use my own xib file. I added a cancel button to the navigation controller linked to the view controller. The cancel button is linked to a method that dismisses the view controller. Here is that method:

- (void)dismissModalWebViewControllerUsingCancelButton:(UIControl *)sender

{

    [_modalWebViewController dismissViewControllerAnimated:YES completion:nil];

}

When I click on the cancel button I get the following error:

Error Domain=com.google.GTMOAuth2 Code=-1000 "The operation couldn’t be completed. (com.google.GTMOAuth2 error -1000.)"

I managed to make the error message disappear by modifying the method as follows:

- (void)dismissModalWebViewControllerUsingCancelButton:(UIControl *)sender

{

    [_modalWebViewController cancelSigningIn];

    [_modalWebViewController dismissViewControllerAnimated:YES completion:nil];

}

Now it works but the webview disappears without animation and then the navigation bar slides down and disappears. It's really ugly.

So the question is, how can I dismiss the view controller in an elegant way without getting any error messages please?

Greg Robbins

unread,
Apr 1, 2013, 7:14:53 PM4/1/13
to gtm-o...@googlegroups.com
The error is intentional, indicating that the user did not sign in. The app should look for [error code] == kGTMOAuth2ErrorWindowClosed and [[error domain] isEqual:kGTMOAuth2ErrorDomain]


Reply all
Reply to author
Forward
0 new messages