문제

I am using OAuth2 to log into Instagram. To do this, you need a webview, which loads a webpage with login fields and login button.

How do I detect if the login button was pressed in the webview so that I can dismiss the modal that the webview is presented in?

Is there any way to catch the request after I press login in the webview? Can I use isViewLoaded?

도움이 되었습니까?

해결책

I use this to detect whether user logins successfully:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
 NSString *urlStr = LOGIN_OK_URL;
 NSString *urlStr1 = LOGIN_OK_URL_1;
 if([URLString hasPrefix:urlStr] || [URLString hasPrefix:urlStr1]){
   // login successfully, dismiss this view 
 } else if ([URLString hasPrefix:URL_LOGIN_CANCEL] == 1 || [URLString isEqualToString:URL_LOGOUT_CANCEL]) {
   // user presses cancel button, dismiss this view
 }
   // processing login page
 return YES

}

Detect the login button was pressed: how to intercept Button click inside UIWebview on IOS?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top