UIWebView 的 shouldStartLoadWithRequest 有时不会被调用

发布于 2024-12-21 06:03:39 字数 673 浏览 6 评论 0原文

我在应用程序中使用 UIWebView ,并重写 shouldStartLoadWithRequest 消息来检测正在单击的链接类型。如果它是一个“特殊”链接,我会将 UIViewController 压入堆栈并从此方法返回 NO。这在大多数时候都很有效。

然而,有时,我点击一个链接,我的 shouldStartLoadWithRequest 永远不会被调用。现在奇怪的是,容纳 UIWebView 的 UIViewController 位于 UITabBarController 中,当我单击另一个选项卡时,UIWebView 最终获得了它的 shouldStartLoadWithRequest叫。在我单击另一个选项卡之前,我不会收到对 shouldStartLoadWithRequest 的调用。另一个有趣的地方是,当我第一次点击链接时,失败的情况永远不会发生。它总是在随后的时间。

有人见过这个吗?对我来说,这听起来像 UIWebView 有时没有获得 touchEnded 事件,并且通过切换选项卡,底层框架会强制发生 touchEnded 事件,这反过来会导致我的 shouldStartLoadWithRequest被叫。

I am using a UIWebView in my app and I am overriding the shouldStartLoadWithRequest message to detect what kind of link is being clicked. If it's a "special" link, I push a UIViewController onto the stack and return NO from this method. This works just dandy most of the time.

Sometimes, however, I click on a link and my shouldStartLoadWithRequest never gets called. Now what's weird is that the UIViewController which houses the UIWebView is in a UITabBarController and when I click on another tab, the UIWebView finally gets its shouldStartLoadWithRequest called. Until I click this other tab, I do NOT get a call to shouldStartLoadWithRequest. The other interesting bit is that the failure case never happens the first time I click on a link; it's always on a subsequent time.

Has anyone seen this? To me, this sounds like the UIWebView is, sometimes, not getting a touchEnded event and by switching tabs, the underlying framework is forcing a touchEnded event which in turn causes my shouldStartLoadWithRequest to get called.

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

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

发布评论

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

评论(1

一枫情书 2024-12-28 06:03:39

您是否正在实现

– webView:didFailLoadWithError:

UIWebViewDelegate 中的方法?也许您在请求中收到错误,然后您就再也没有看到它?当您遇到超时和其他问题等问题时,应该抛出该委托。

Are you implementing the

– webView:didFailLoadWithError:

method from the UIWebViewDelegate? Perhaps you're getting an error on the request and then you're never seeing it? This delegate should get thrown when you have issue such as timeouts and other things.

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