在 Cocoa Touch Webview 开始加载之前验证用户触摸的链接

发布于 2024-12-12 04:39:59 字数 170 浏览 0 评论 0原文

有一位潜在客户问我是否可以阻止用户在 iPad 应用程序中离开他们的网站?因此,我需要在网络视图中加载客户端站点,并以某种方式禁用无效链接,即横幅和促销链接。

我想知道是否有一种方法可以在加载之前捕获视图中已触摸的链接。

如果没有办法做到这一点,是否可以在将网页加载到网络视图之前去除无效链接?

I had a potential client ask me if I can prevent a user navigating away from their website within an iPad app? So I would need to load the client site within a web view and somehow disable invalid links i.e. banners and promotional links.

I am wondering if there is a way to catch the link that has been touched within the view before it is loaded.

If there is no way to do this, is there away to strip a web page of invalid links before it is loaded into the web view?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

GRAY°灰色天空 2024-12-19 04:39:59

使用 UIWebViewDelegate 方法 webView:shouldStartLoadWithRequest:navigationType:。当用户点击链接时调用它。如果您不想处理任何链接,则返回 NO;如果您希望 Web 视图处理请求,则返回 YES。更多信息请参阅 Apple 文档

一件好事是过滤掉一些请求并根据请求的 URL 方案或基于 UIWebViewNavigationType 值自行处理它们。注意:对于您处理的过滤请求,您仍然返回NO

Use UIWebViewDelegate method webView:shouldStartLoadWithRequest:navigationType:. It's called when user taps a link. Return NO if you don't want to handle any links or YES if you want your web view to handle the request. More info in Apple docs.

A nice thing is to filter out some requests and handle them yourself based on e.g. URL-scheme of the request or based on UIWebViewNavigationType value. Note: for a filtered requests that you handle, you still return NO.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文