How do I add a UIActivity Indicator to every Cell and maintain control of each individual indicator

前端 未结 4 1885
隐瞒了意图╮
隐瞒了意图╮ 2021-01-21 14:39

I\'m trying to add an activity indicator to certain cells in my UITableView. I do this successfully in the method didSelectRowAtIndexpath using

    CGRect CellFr         


        
4条回答
  •  独厮守ぢ
    2021-01-21 14:59

    You can add UIActivityIndicatorView as cell's accessoryView.

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
        UIActivityIndicatorView *spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
        spinner.frame = CGRectMake(0, 0, 24, 24);
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        cell.accessoryView = spinner;
        [spinner startAnimating];
        [spinner release];
    }
    

提交回复
热议问题