0

我搜索了很多论坛,但没有找到,我的问题是

我需要从网络上预加载一些数据以加载到 UITableView。

我看到一些应用程序解决了这个问题,当显示 UITableView 时,它们将“等待圆圈”显示为模态视图,并且在加载数据后只是隐藏这个圆圈。

  1. 有没有简单的解决方案来做到这一点?
  2. 我需要做什么?
  3. 我需要什么样的请求:同步还是异步?
  4. 如何显示这个圈子,我需要显示animatedGif还是有一些内部/外部控制?
4

2 回答 2

0

您需要为您的“等待圈”-(活动指示器)制作一个 NSThread。

1)线程我如何创建一个不是主线程的 NSThread

2)活动指示器如何使用活动指示器视图

于 2012-05-14T08:46:17.093 回答
0
 - (void)showWaitingView {

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

CGRect frame = CGRectMake(90, 190, 32, 32);
UIActivityIndicatorView* progressInd = [[UIActivityIndicatorView alloc] initWithFrame:frame];
[progressInd startAnimating];
progressInd.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;

frame = CGRectMake(130, 193, 140, 30);
UILabel *waitingLable = [[UILabel alloc] initWithFrame:frame];
waitingLable.text = @"Processing...";
waitingLable.textColor = [UIColor whiteColor];
waitingLable.font = [UIFont systemFontOfSize:20];;
waitingLable.backgroundColor = [UIColor clearColor];
frame = [[UIScreen mainScreen] applicationFrame];
UIView *theView = [[UIView alloc] initWithFrame:frame];
theView.backgroundColor = [UIColor blackColor];
theView.alpha = 0.7;
theView.tag = 999;
[theView addSubview:progressInd];
[theView addSubview:waitingLable];

[progressInd release];
[waitingLable release];

[window addSubview:[theView autorelease]];
[window bringSubviewToFront:theView];
[pool drain];
  }

 - (void)removeWaitingView {
UIView *v = [window viewWithTag:999];
if(v) [v removeFromSuperview];

}
于 2012-05-14T09:09:58.163 回答