简体   繁体   English

如何在滚动视图甚至未出现在屏幕上之前加载活动指示器?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM