UIWebView 的 shouldStartLoadWithRequest 有时不会被调用
我在应用程序中使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否正在实现
UIWebViewDelegate 中的方法?也许您在请求中收到错误,然后您就再也没有看到它?当您遇到超时和其他问题等问题时,应该抛出该委托。
Are you implementing the
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.