2
在我的UITableViewController子类中,我想准备表格数据并在视图已经出现后重新加载表格(因此表格最初加载为空)。在我的应用程序委托中,我有方法来生成和删除活动屏幕。我的问题似乎是活动视图呈现被延迟到reloadData调用完成之后。我通过删除hideActivity行证明了这一点,并且确实我的活动视图与重新加载表同时出现。这里的viewDidAppear为我的视图控制器...子视图呈现延迟
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[(AppDelegate *)[[UIApplication sharedApplication] delegate] showActivity];
[self prepare];
[self.tableView reloadData];
[(AppDelegate *)[[UIApplication sharedApplication] delegate] hideActivity];
}
我假设这可能与没有重绘中期方法的意见去做,但在此之前不记得这种情况的发生。有任何想法吗?
...虽然我知道他们的工作,这是我的活动方法。也许我这样做的方式允许某种延迟的外观...
- (void)showActivity
{
self.activityView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 480.0f)];
self.activityView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.75f];
UIActivityIndicatorView *spinner = [[[UIActivityIndicatorView alloc] initWithFrame:CGRectMake((320.0f/2.0f) - (37.0f/2.0f), (480.0f/2.0f) - (37.0f/2.0f) - (20.0f/2.0f), 37.0f, 37.0f)] autorelease];
spinner.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[spinner startAnimating];
UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0f, spinner.frame.origin.y + spinner.frame.size.height + 10.0f, 320.0f, 30.0f)] autorelease];
label.textAlignment = UITextAlignmentCenter;
label.text = @"Working";
label.textColor = [UIColor whiteColor];
label.backgroundColor = [UIColor clearColor];
[self.activityView addSubview:label];
[self.activityView addSubview:spinner];
[self.window addSubview:self.activityView];
}
- (void)hideActivity
{
[self.activityView removeFromSuperview];
[self.activityView release];
}
谢谢,这很奏效。 – rob5408 2011-01-13 22:21:53