我有一个问题。
我有表格视图,当我单击单元格时,我从服务器加载数据。因为这可能需要一些时间,所以我想显示活动指示器视图。
-(void)startSpiner{
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIView * background = [[UIView alloc]initWithFrame:screenRect];
background.backgroundColor = [UIColor blackColor];
background.alpha = 0.7;
background.tag = 1000;
UIActivityIndicatorView * spiner = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
spiner.frame = CGRectMake(0, 0, 50, 50);
[spiner setCenter:background.center];
[spiner startAnimating];
[background addSubview:spiner];
[background setNeedsDisplay];
[self.view addSubview:background];
}
这很好用,但是当我把它放进去时
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
[self startSpiner];
Server *server = [[Server alloc]init];
self.allItems = [server getDataGLN:self.object.gln type:1];
}
我看到 UIActivityIndicatorView 在从服务器获取数据后显示。如何强制主视图立即更新?