TableViewCell自定义折叠

---恢复内容开始---

 

主要是通过两个代理方法:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if ([[self.selectArray objectForKey:indexPath]  isEqual: @"100"]) {
        return 100;
    }else {
        return 44;
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell.frame.size.height == 44) {
        [self.selectArray setObject:@"100" forKey:indexPath];
    }else {
        [self.selectArray removeObjectForKey:indexPath];
    }
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}

 

---恢复内容结束---

posted @ 2015-12-10 16:55  DevoutSoul  阅读(266)  评论(0)    收藏  举报