[英]How to load an activity indicator before scrollview even appears on my screen?
I am showing a scrollview on the screen and populating content and before it even appears on my screen i wanted to load a activity indicator view. 我正在屏幕上显示滚动视图并填充内容,在它还没有出现在屏幕上之前,我想加载一个活动指示器视图。 i know how to do it using webview methods like below but not for scrollview , can somebody help me with the right methods for scrollview.
我知道如何使用如下所示的webview方法执行此操作,但对于scrollview不行,有人可以为我提供正确的scrollview方法帮助我。
-(void)webViewDidStartLoad:(UIWebView *)webView{
}
(void)webViewDidFinishLoad:(UIWebView *)webView {
}
There are no such methods for the scrollView
because it is just a container for other views, there is no implicit loading involved like with the webView
. scrollView
没有这种方法,因为它只是其他视图的容器,没有像webView
这样的隐式加载。
Therefore, you will have to keep track of the state of the content manually. 因此,您将必须手动跟踪内容的状态。 One solution would be to add the
activityIndicator
in viewWillAppear:
or awakeFromNib
(depending if you are implementing your logic in the viewController
or a custom UIView
). 一种解决方案是在
viewWillAppear:
或awakeFromNib
添加activityIndicator
(取决于您是在viewController
还是自定义UIView
中实现逻辑)。
Then when your content is loaded, for example in the webView
delegate
methods, you stop the animating and, eventually, make the webView
visible, if you want this kind of animation. 然后,在加载内容时(例如,在
webView
delegate
方法中),如果需要这种动画,则停止动画设置,并最终使webView
可见。
Let me know if you need more help or have any questions. 让我知道您是否需要更多帮助或有任何疑问。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.