调用pushViewController这里是我的代码...无法获得UIActivityIndicator露面,而在didSelectRowAtIndexPath方法
- (void) threadStartAnimating {
[activityIndicator startAnimating];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
activityIndicator=[[UIActivityIndicatorView alloc] init];
[activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center=[self tableView].center;
[[self tableView] addSubview:activityIndicator];
[NSThread detachNewThreadSelector:@selector(threadStartAnimating) toTarget:self withObject:nil];
EventController *eventController = [[EventController alloc] init];
[eventController setEventID:[[lineItems objectAtIndex:[indexPath row]] objectForKey:@"view_event_button_param"]];
[activityIndicator stopAnimating];
[[self navigationController] pushViewController:eventController animated:YES];
}
事件控制器包含一个Web服务,需要几秒钟的加载。我能得到活动指示器显示的唯一方法是如果我在那里抛出一个无限循环...我发现了一堆提到将它放在一个单独的线程中的例子,但它似乎不起作用。
那么'EventController'从它的'init'方法从web服务加载东西呢?或者其他地方 – mattjgalloway 2012-01-10 22:21:16
是的,eventControllers viewDidLoad方法调用我的方法loadDataIntoView它调用Web服务 – 2012-01-10 22:36:35
然后看到我的答案。 – mattjgalloway 2012-01-10 22:41:48