我有一个表格视图,在其中有一个UIActivityIndicator和一个按钮,每个单元格中都有一个。现在当点击该按钮时,我想要开始ActivityIndicator的动画,它已经开始了。但问题是当我滚动表格视图时,它停止了动画。这是我的cellForRowAtIndexPath的代码:
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"txDevicesListCellID"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"txDevicesListCellID"];
}
UIButton *buttonutton = (UIButton *)[cell viewWithTag:103];
UIActivityIndicatorView *activityIndicator = (UIActivityIndicatorView *) [cell viewWithTag:104];
button.tag = indexPath.row;
return cell;
}
我的按钮的 and 选择器方法是
-(IBAction)recevierButtonClick:(id)sender{
UIButton *button = (UIButton *)sender;
NSInteger index = button.tag;
NSIndexPath* indexpath = [NSIndexPath indexPathForRow:serialNumber inSection:0];
UITableViewCell* cell = [self.myTableView cellForRowAtIndexPath:indexpath];
activityIndicator = (UIActivityIndicatorView*)[cell viewWithTag:index];
[activityIndicator startAnimating];
}