Hopefully I am understanding your question correctly: You want to click on a cell and have an activity indicator start animating?
I personally wouldn't bother with having an activity indicator on all of them and then hiding and revealing them, it makes it a bit of a pain to start and stop the correct indicators.
How I have done it in other apps is to add an indicator to the cell at the didSelectRow stage as we can know which cell we have clicked and immediately add a cell:
- (void)tableView:(UITableView *)tableView_ didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView_ reloadData];
// This code will create and add an activity indicator
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UITableViewCell * cell = [tableView_ cellForRowAtIndexPath:indexPath];
cell.accessoryView = activityIndicator;
[activityIndicator startAnimating];
[tableView_ deselectRowAtIndexPath:indexPath animated:YES];
}
The neat thing about this code is that as we don't add the activity indicator when creating the cell means we can get rid of the indicator by refreshing the tableView. In this case each time we click we get rid of the previous indicator and add a new one.
Hopefully this helps a bit
EDIT: If you want this to occur from pressing a button in a cell (thanks to Vladimir for this answer)
This is pretty simple again and can use the code above.
Add a target to the button when creating the cell:
[button addTarget:self action:@selector(checkButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
This will enable us to find out when the button is tapped
- (void)checkButtonTapped:(id)sender {
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
// Now we have the indexPath of the cell clicked so we can use the previous code again
[tableView_ reloadData];
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
UITableViewCell * cell = [tableView_ cellForRowAtIndexPath:indexPath];
cell.accessoryView = activityIndicator;
[activityIndicator startAnimating];
}