在 UIWebView 中单击时,shouldStartLoadWithRequest 不加载链接
我已经开始使用 shouldStartLoadWithRequest 并在我理解的情况下遇到了令人费解的行为。在最简单的形式中,我尝试了以下操作...
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
当我单击 HTML 链接时,链接不会在 UIWebView 中加载新页面。我很可能没有完全理解这里的一些东西。任何反馈/帮助将不胜感激。
I've started using shouldStartLoadWithRequest and been encountering puzzling behaviour as I understand things. In it's most simplest form I've tried the following...
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
With the side effect of when I click on HTML links the links do not load new pages in the UIWebView. Very likely I am not understanding something completely here. Any feedback/help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两种可能的原因
1>要么你没有设置委托
将您的网络视图委托给您的班级
即在
viewDidLoad
方法中(如果 webView 是在 xib 文件中获取的,则需要从 sib 文件中设置委托)
2> 您的类未实现 UIWebViewDelegate 协议
即在你的接口声明中你还没有这样声明它
Two Possible reason
1> either you have not set the delegate
Set delegate your webview to your class
i.e in
viewDidLoad
method(if webView is taken in xib file you need to set the delegate from sib file)
2> your class does not implement UIWebViewDelegate protocol
i.e. in your interface's declaration you haven,t declare it like this