I have 5 cells in a tableview that are all custom. Meaning, I've created a xib with a tableviewcell and created a corresponding cellController. The xib has two labels named name and size. The user taps a row, triggering didSelectRowAtIndexPath. From there a timer is started. At some point the timer finishes. Here I need to assign text to the selected cell's name label. How do I get the selected cell reference and keep it for assigning? Or, is there a better way to do it?
+1
A:
The UITableView instance method
-(UITableViewCell*) cellForRowAtIndexPath: (NSIndexPath*)indexPath
will allow you to get a pointer to the cell.
Simply store the row+section info from NSIndexPath argument of the didSelectRowAtIndexPath event. Then, when the timer finishes, build a new NSIndexPath and call cellForRowAtIndexPath. Also be prepared for it to return nil if the cell is no longer in view.
CynicismRising
2009-05-16 05:24:13
Thanks. At the same location on timer completion, I'd like to widen the particular tableview cell that I just retrieved. I tried cell.NameLabel.width = 241; but it doesn't have any affect. I can modify the label font attributes though without issue. I did try calling [self.tableView reloadData]; but it didn't have any affect. Is there a way to do it?
4thSpace
2009-05-16 14:30:30