简体   繁体   中英

Saving reference to UITableViewCell

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM