The accossoryView of a UITableViewCell disappears after the visible view is changed

Posted by Luca on Stack Overflow See other posts from Stack Overflow or by Luca
Published on 2011-01-09T23:47:58Z Indexed on 2011/01/09 23:53 UTC
Read the original article Hit count: 428

Hi! I'm experiencing this strange situation. I have a UITableView where, when the user selects a cell, a long (network) process begins. So, I performed this in a background thread and I placed (in the didSelectRowAtIndexPath) a UIActivityIndicatorView as the accessory view. This is what I wrote:

UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
UIActivityIndicatorView* activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
cell.accessoryView = activityView;
[activityView startAnimating];
[activityView release];

everything seems to work correctly, except that, if during a loading process (when the indicator is animated), I switch the view using a UITabBar, when I go back to the UITableView, the UIActivityIndicatorView that should still be there has disappeared. Any idea of what I did wrong? Thanks!

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about iphone-sdk-4.0