【发布时间】:2011-11-21 02:39:31
【问题描述】:
在我目前正在处理的 iPhone 项目中,其中一个要求是,当用户单击由 UIViewController 管理 UIWebView 维护的页面上的链接时,应显示 UIAlertView。仅当用户未单击警报的取消按钮时,才应加载链接指向的网页。更进一步的细节是,这个特定的控制器是基本 Web 视图控制器类的子类,因此在某些情况下,请求加载需要推迟到这个超类。简而言之:
1. User clicks on a link
2. Inspect link n webView:shouldStartLoadWithRequest:navigationType:
3. Depending on the link, show a UIAlertView
4. If the user presses Cancel, the alert is dismissed and the request is NOT loaded
5. If the user presses Continue, the alert is dismissed and the request is loaded
我尝试覆盖webView:shouldStartLoadWithRequest:navigationType:,然后根据链接显示警报。但是,后来我意识到,当按下警报按钮之一时发生的任何事件都将在回调中发生,例如alertView:clickedButtonAtIndex:。我尝试这样做并且应用程序被锁定。
我猜有一种方法可以做到这一点,但它可能不太直接,我应该尝试显示自定义的模态UIView,它可以完成与我尝试对警报执行的操作相同的操作。
点击会有帮助。
【问题讨论】:
标签: iphone objective-c cocoa-touch uiwebview