NetworkActivityIndicator 在 iPhone 和模拟器上的工作方式不一样?
我正在使用 NetworkActivityIndicator 来显示我的应用程序正在执行一些工作。当我在模拟器中运行应用程序时,它显示了我想要的方式 - 基本上一直旋转,直到选定的选项卡从服务器加载数据 - 但当我将应用程序放到手机上时,我只得到了瞬间在旋转器消失之前。通常仅在视图出现在屏幕上之前旋转。
有想法吗?
编辑:问题可能与我使用 TabBar 的事实有关...在模拟器中,当加载 Screen/Tab 2 时,ActivityIndicator 将在 Screen/Tab 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
}
I am using the NetworkActivityIndicator to show that my App is doing some work. When I run the app in the simulator, it shows the way I want - basically spinning the entire time until the selected tab loads the data from the server - but when I put the app onto my phone, I only get a split-second of the spinner before it disappears. Usually only spins right before the view appears on the screen.
Ideas?
EDIT: The problem might have to do with the fact I am using a TabBar... In the simulator the ActivityIndicator will spin on Screen/Tab 1 while Screen/Tab 2 is loading. On the phone, I only see the ActivityIndicator for a split second after Screen 2 finally appears.
-(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
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你在这里打开旋转器......
但你立即将其关闭......
当然它不会显示。我很惊讶它在模拟器中显示。
-doneSpinning
方法应该在-getDataFromServer
完成后调用,或者直接执行You turn on the spinner here…
But immediately you turn it off…
Of course it won't show. I'm surprised it shows in the simulator.
The
-doneSpinning
method should be called after-getDataFromServer
is done, or just do