Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 使用UIAlertView有条件地加载web请求_Iphone_Objective C_Cocoa Touch_Uiwebview - Fatal编程技术网

Iphone 使用UIAlertView有条件地加载web请求

Iphone 使用UIAlertView有条件地加载web请求,iphone,objective-c,cocoa-touch,uiwebview,Iphone,Objective C,Cocoa Touch,Uiwebview,在我目前正在进行的iPhone项目中,其中一个要求是,当用户单击由UIViewController管理UIWebView的页面上的链接时,应显示UIAlertView。仅当用户未单击警报的“取消”按钮时,才应加载链接指向的网页。更详细的是,这个特定的控制器是基本web视图控制器类的一个子类,因此在某些情况下,请求加载需要延迟到这个超类。简言之: 1. User clicks on a link 2. Inspect link n webView:shouldStartLoadWithReques

在我目前正在进行的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:clickedbuttonationindex:
。我尝试过这样做,但应用程序被锁定了

我猜有一种方法可以做到这一点,但它可能不太直接,我应该尝试显示自定义的模式
UIView
,它完成了与我尝试对警报所做的相同的事情


点击会很有帮助。

显示警报并将原始请求存储在视图控制器的某些属性中。然后立即从委托方法返回
NO
shouldStartLoadWithRequest:…

实现
alertView:ClickedButtonIndex:
并加载先前存储在属性中的请求,如果用户选择Continue。。。(如果选择了“取消”,则无需执行任何操作)