Stine Stine - 1 month ago 10
iOS Question

UIActivityIndicatorView stops spinning

I am experiencing that when I add a

UIActivityIndicatorView
as a subview of one of my
UITableViewCell
s then it only spins for a short while and then it stops. Does anyone maybe know why?

This is in principle what I am doing in my code:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyCell" forIndexPath:indexPath];

if (indexPath.row == 0) cell.accessoryView = spinner;

UILabel *label = (UILabel *)[cell viewWithTag:1];
label.text = @"Some text";

return cell;
}


where
spinner
is an
IBOutlet
:

IBOutlet UIActivityIndicatorView *spinner;

Answer Source

Try inserting this inside the function.

[spinner startAnimating];

If you want it to stop, call the stopAnimating method.