开发者

Tableview cell change cell backgroung image(png) on click

开发者 https://www.devze.com 2023-02-07 17:19 出处:网络
I want to highlit cell when user click on the cell in the function didselectrowatindexpath.开发者_开发百科?You have two options:

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

精彩评论

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