When processing some data in the background which is specific to a table view cell, I would like to put the table view cell’s view in a semi-transparent mode and put a progress indicator view on top of the table view cell.
I tried the following code, but no activity indicator is shown:
-(void)showActivityIndicatorInTableView:(UITableView*)tableView
atIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
UIView *view = [[UIView alloc] initWithFrame:cell.contentView.frame];
view.tag = 50;
UIActivityIndicatorView *ac = [[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
CGRect frame = view.frame;
ac.center = CGPointMake(frame.size.width/2, frame.size.height/2);
[view addSubview:ac];
[ac startAnimating];
}
What is wrong with my code? What would be a better way to implement this? How could I show the indicator view in a semi-transparent view which overlays the table view cell?
Thank you!
From the looks of it, you’re never adding the UIView you created to your cell. You might want to do the following:
Also, you might want to change the frame of the view you add to your cell to something different than the actual cell. This will allow you to scroll within your
UITableViewwithout disturbing the worker view you setup.To make the view semi-transparent: