我有tableview
回复detialview
。在detailview
我有一些从URL加载的图像和实验。我正在尝试向单元格添加UIActivityindicatorview
以显示正在加载。我已经处理过了,但是当我回到tableview
时,它显示得很晚,并且不会消失。我已经到处寻找一个简单的解决方案,但失败了......
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ReaDetailViewController *reaDetail = [[ReaDetailViewController alloc] initWithNibName:@"ReaDetailViewController" bundle:nil];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView *activityView =
[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[activityView startAnimating];
[cell setAccessoryView:activityView];
[activityView release];
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
{
reaDetail.petImageString = [[NSString alloc] initWithString:[[exclusiveArray objectAtIndex:indexPath.row] objectForKey:@"image"]];
reaDetail.petLabelString = [[NSString alloc] initWithString:[[exclusiveArray objectAtIndex:indexPath.row] objectForKey:@"description"]];
reaDetail.petLabelString1 = [[NSString alloc] initWithString:[[exclusiveArray objectAtIndex:indexPath.row] objectForKey:@"description1"]];
reaDetail.petLabelString2 = [[NSString alloc] initWithString:[[exclusiveArray objectAtIndex:indexPath.row] objectForKey:@"description2"]];
reaDetail.title = [[exclusiveArray objectAtIndex:indexPath.row] objectForKey:@"name"];
}
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:reaDetail animated:YES];
[reaDetail release];
}
任何帮助都非常有帮助!
答案 0 :(得分:0)
我了解您希望在加载视图控制器时使活动视图变为动画。问题是,在您从此选择方法返回之前,活动视图不会开始动画...这是关于您的控制器准备好被推动的时间。
然后2个选项:
perfomSelector:onMainThread
来执行视图控制器的初始化步骤viewDidLoad
或viewWillAppear
方法中执行其初始化过程(您可以在此新视图中添加活动控制器)。如果选择第一个选项,则应在推动新视图控制器后调用deselectRowAtIndexPath
方法,并使用此stopAnimating
方法在指标视图上调用deselectRowAtIndexPath
。< / p>