UITableViewCell animate height issue in iOS 10

后端 未结 7 1858
余生分开走
余生分开走 2020-12-13 14:23

My UITableViewCell will animate it\'s height when recognizing a tap. In iOS 9 and below this animation is smooth and works without issues. In iOS 10 beta there\

7条回答
  •  旧时难觅i
    2020-12-13 15:00

    Faced the same issue on iOS 10 (everything was fine on iOS 9), the solution was to provide actual estimatedRowHeight and heightForRow via UITableViewDelegate methods implementation.

    Cell's subviews positioned with AutoLayout, so I used UITableViewAutomaticDimension for height calculation (you can try set it as a tableView's rowHeight property).

    - (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
        CGFloat result = kDefaultTableViewRowHeight;
    
        if (isAnimatingHeightCellIndexPAth) {
            result = [self precalculatedEstimatedHeight];
        }
    
        return result;
     }
    
    
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return UITableViewAutomaticDimension;
    }
    

提交回复
热议问题