UITableView 点击展开的实现

推介看下这里的 内容  http://www.cnblogs.com/kenshincui/p/3931948.html

IOS8 above

UITabliViewCell 利用 autolayout 实现的,这里就不多说了

主要代码

1.

    self.tableView.rowHeight = UITableViewAutomaticDimension;

    self.tableView.estimatedRowHeight = 70;

2.

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    NSLog(@"heightForRowAtIndexPath=:%ld",indexPath.row);

    if( indexPath.row == selectIndex )

    {

        if( !isOpened )

            return 130;

        

        return UITableViewAutomaticDimension;

    }

    else

    {

        return 130;

    } 

}

 

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

    selectIndex = indexPath.row;

    isOpened = !isOpened;

    [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

}

原文地址:https://www.cnblogs.com/rollrock/p/4884705.html