I'm trying to change the background color of a cell after the user enters something in a textfield. I've tried the following code but nothing happens.
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:2];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.backgroundColor = [UIColor grayColor];
Is there anything I don't see?
The only thing I can think of is that you have your section/row number wrong, ie
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:2];
I have two sections in my tableView and it works as long as refer to section 2 as section 1, as section and row numbers start at 0. Apologies in advance if this sounds too obvious, but I do it all the time... :-)
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.