在iPhone上的UITabBar应用程序中的活动指示器 [英] Activity indicator in a UITabBar application on the iPhone
问题描述
我有一个UITabBar + UINavigationController应用程序,它通常需要来自互联网的数据。有时它需要一段时间才会得到它,所以我想显示一个活动指示器。
I have a UITabBar + UINavigationController application which often needs data from the internet. Sometimes it takes quite a while before it gets it, so I would like to show an activity indicator.
我想要的是在我的窗口中添加一个activityView applicationDidFinishLaunching方法:
What I was trying is to add a activityView to my window in my applicationDidFinishLaunching method:
[window addSubview:tabBarController.view];
fullscreenLoadingView.hidden = YES;
[window addSubview:fullscreenLoadingView];
然后我将应用程序委托作为观察者添加到默认通知中心:
And then I add the application delegate as a observer to the default notification center:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startFullscreenLoading:) name:@"startFullscreenLoading" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(stopFullscreenLoading:) name:@"stopFullscreenLoading" object:nil];
并实施方法:
- (void)startFullscreenLoading:(NSNotification *)notification {
fullscreenLoadingView.hidden = NO;
}
- (void)stopFullscreenLoading:(NSNotification *)notification {
fullscreenLoadingView.hidden = YES;
}
当我在applicationDidFinishLaunching方法中直接使用它时,加载指示器视图显示upp
When I then use this directly in the applicationDidFinishLaunching method the loading indicator view shows upp as expected:
[[NSNotificationCenter defaultCenter] postNotificationName:@"startFullscreenLoading" object:self];
但是当我从一个导航控制器使用它时,startFullscreenLoading:方法被调用,见装载指示器视图。为什么?
But when I use it from one of the navigation controllers the startFullscreenLoading: method is called but I don't see the loading indicator view. Why is that?
推荐答案
您是在后台线程上加载数据吗?你的主线程将被阻塞&将无法重绘或处理任何其他事件。
Are you loading your data on a background thread? Your main thread will be blocked & won't be able to redraw or process any other events.
这篇关于在iPhone上的UITabBar应用程序中的活动指示器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!