【发布时间】:2009-07-10 12:54:04
【问题描述】:
我有一个 UITabBar + UINavigationController 应用程序,它经常需要来自互联网的数据。有时它需要很长时间才能得到它,所以我想显示一个活动指示器。
我正在尝试在我的 applicationDidFinishLaunching 方法中向我的窗口添加一个 activityView:
[window addSubview:tabBarController.view];
fullscreenLoadingView.hidden = YES;
[window addSubview:fullscreenLoadingView];
然后我将应用程序委托作为观察者添加到默认通知中心:
[[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:
[[NSNotificationCenter defaultCenter] postNotificationName:@"startFullscreenLoading" object:self];
但是当我从其中一个导航控制器中使用它时,会调用 startFullscreenLoading: 方法,但我看不到加载指示器视图。这是为什么呢?
【问题讨论】:
标签: iphone cocoa-touch