Can you animate a height change on a UITableViewCell when selected?

前端 未结 21 1329
天涯浪人
天涯浪人 2020-11-22 04:41

I\'m using a UITableView in my iPhone app, and I have a list of people that belong to a group. I would like it so that when the user clicks on a particular pers

21条回答
  •  暖寄归人
    2020-11-22 04:52

    BOOL flag;
    
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        flag = !flag;
        [tableView beginUpdates];
        [tableView reloadRowsAtIndexPaths:@[indexPath] 
                         withRowAnimation:UITableViewRowAnimationAutomatic];
        [tableView endUpdates];
    }
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return YES == flag ? 20 : 40;
    }
    

提交回复
热议问题