Objective-C中如何区分链接请求
我在 UIViewController 中有以下方法:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType.
我的 webview 在视图中有两个链接;我希望能够区分两者,以便我知道用户单击了哪一个。
有人知道怎么做吗?
I have the following method in a UIViewController:
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType.
My webview has two links in the view; I want to be able to distinguish between the two of them so that I know which one the user clicked on.
Does anyone know how to?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须从 NSURLRequest 中提取 url 字符串:
然后使用 currentPath 与您的两个 URL 进行比较。如果这些 URL 未知,您应该解析 html 文件以在其中找到它们。您无法通过 UIWebView 访问 HTML 文档结构,因为它非常复杂。
You must extract a url string from NSURLRequest:
Then use currentPath to compare with your two URLs. If those URL are unknown you should parse your html file to find them in it. You cannot get access to HTML document structure through UIWebView because it is extremely complicated.