iOS:活动指示器和WebView

时间:2013-05-23 09:17:13

标签: ios uiwebview uiactivityindicatorview

我有一个场景,当文档需要时间在webview中下载时,用户可以按活动指示器中提供的取消按钮并停止下载。我正在使用不同的库来进行活动指示。我需要在webview中知道按钮已在活动指示器中单击,或者如何在活动指示器库中访问webview。我可以在其他文件中设置活动指示器取消按钮选择器方法吗?非常感谢快速帮助。

2 个答案:

答案 0 :(得分:1)

您可以使用DelegationNotification告诉包含UIWebView的类,在另一个类(您的活动指示器类)中按下了取消按钮。

答案 1 :(得分:0)

您可以使用NSNotificationCenter获取按下取消按钮事件:

添加观察者

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cancelButtonClicked:) name:@"cancelButton" object:nil];

实施取消方法

-(void)cancelButtonClicked:(NSNotification *)notification{
   // Do your action here
}

并且不要忘记在取消后删除观察者:

[[NSNotificationCenter defaultCenter] removeObserver:self];

详细信息请查看以下内容:

Send and receive messages through NSNotificationCenter in Objective-C?

相关问题