0

I have a simple app, with only a login page. When the user sing-in, I load a webview running an entire html5 app.

The point is that I would like to capture when the user has decided to logout.

Is there any way to listen when a specific url has been loaded?

If so, when the user press logout and the /logout.html would be loaded and I would have the opportunity of returning the control to the iOS app.

4

1 回答 1

0

符合 .h 文件中的 UIWebViewDelegate

设置你的 UIWebview 代表

实现以下方法:

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
NSLog(@"URL Request = %@",[[[webView request] URL] lastPathComponent]);
//    if (check stringlogout.html) {
//        return NO;
//    }
//    else{
//        return YES;
//    }
return YES;
}

检查你的最后一个组件字符串,如果它是 logout.html,那么你可以做需要的东西,否则你可以做如果它不是 logout.html 动作。

如果要加载页面,则返回 YES,如果不想加载页面,则返回 NO。

祝你的应用好运...

于 2013-10-11T11:49:57.203 回答