我有一个应用程序使用UITableViews和从服务器获取数据。我正在尝试在UITableView上放置一个UIActivityIndicatorView,因此它在加载Child UITableView的同时进行了旋转。我有UIActivityIndicatorView通过Interface Builder中,所有hookedup等UIActivityIndicatorView不旋转,直到我回到父UITableView
-(void)spinTheSpinner {
NSLog(@"Spin The Spinner");
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[spinner startAnimating];
[NSThread sleepForTimeInterval:9];
[self performSelectorOnMainThread:@selector(doneSpinning) withObject:nil waitUntilDone:NO];
[pool release];
}
-(void)doneSpinning {
NSLog(@"done spinning");
[spinner stopAnimating];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[NSThread detachNewThreadSelector:@selector(spinTheSpinner) toTarget:self withObject:nil];
NSMutableString *tempText = [[NSMutableString alloc] initWithString:[categoryNumber objectAtIndex:indexPath.row]];
Threads *viewController = [[Threads alloc] initWithNibName:@"newTable" bundle:nil tagval:tempText SessionID:PHPSESSID];
[self.navigationController pushViewController:viewController animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
[viewController release];
}
所以,当我推儿童的UITableView在屏幕上时,UIActivityIndicatorView(微调)只是坐在那里对家长的UITableView。如果我转到Child UITableView并快速返回到父视图,我可以在旋转的动作中捕捉到UIActivitIndicatorView。 NSLogs显示在正确的时间 - 当我第一次点击Parent UITableView中的单元格时,“Spin The Spinner”出现在Log中。 9秒后,我在Log中完成了“完成旋转”,但是除非我及时弹回到Parent UITableView,否则微调不会旋转。
想法为什么这不能正常工作?
这工作。谢谢,怀疑我很快就会发现。 我结束了sleepForTimeInterval并设置waitUntilDone:NO,并达到相同/所需的效果。 – Chris 2010-03-06 18:49:33