Stine
Stine

Reputation: 1665

UIActivityIndicatorView stops spinning

I am experiencing that when I add a UIActivityIndicatorView as a subview of one of my UITableViewCells 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;

Upvotes: 3

Views: 567

Answers (2)

T Chad
T Chad

Reputation: 72

Try inserting this inside the function.

[spinner startAnimating];

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

Upvotes: 2

Alexander Gattringer
Alexander Gattringer

Reputation: 175

You need to manually start and stop the animation of the UIActivityIndicatroView. Example for your code

Add this where you want to start the animation:

[spinner startAnimating];

Add this where you want to stop the animation:

[spinner stopAnimating];

Hope this helps!

Upvotes: 1

Related Questions