我正在使用NetworkActivityIndicator来显示我的应用程序正在做一些工作。当我在模拟器中运行应用程序时,它会显示我想要的方式 - 基本上旋转整个时间,直到选定的选项卡从服务器加载数据 - 但是当我将应用程序放到手机上时,我只得到一瞬间旋转器消失之前。通常只在视图出现在屏幕上之前旋转。
想法?
编辑:问题可能与我使用TabBar的事实有关...在模拟器中,当屏幕/标签2加载时,ActivityIndicator将在屏幕/标签1上旋转。在电话上,我只在屏幕2终于出现后一瞬间看到ActivityIndicator。
-(void)viewDidLoad {
// call to spinTheSpinner
[NSThread detachNewThreadSelector:@selector(spinTheSpinner) toTarget:self withObject:nil];
// method to Get the Data from the Server
[self getDataFromServer];
}
-(void)spinTheSpinner {
NSLog(@"Spin The Spinner");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
[self performSelectorOnMainThread:@selector(doneSpinning) withObject:nil waitUntilDone:YES];
[pool release];
}
-(void)doneSpinning {
NSLog(@"done spinning");
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
-(void)getDataFromServer {
// does a bunch of stuff to retrieve and display data
}
答案 0 :(得分:0)
你在这里打开微调器......
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
但是你马上把它关了......
[self performSelectorOnMainThread:@selector(doneSpinning) …];
当然不会显示。我很惊讶它在模拟器中显示出来。
-doneSpinning
完成后,-getDataFromServer
方法应该被称为,或者只是
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
[self getDataFromServer]; // assumes it is blocking.
app.networkActivityIndicatorVisible = NO;