开发者

Tableview cell change cell backgroung image(png) on click

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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜