I want to highlit cell when user click on the cell in the function didselectrowatindexpath.开发者_开发百科?
You have two options:
- modify the cell directly in your
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
method (but I've had some visual glitch issues with this technique, Problem modifying UITableViewCell accessoryType in tableView:didSelectRowAtIndexPath:):
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
// do stuff with cell
//
}
- set appropriate state in your data model, and call
[tableView reloadData]
, which in turn will result in a call to- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
, where you set up the cell to display according to your data model.
精彩评论