5

In my app, I was using tableview.begingUpdates() to animate the change of my tableviewcell heigh (expansion and collision of an image). It was working tip-top on iOS 8.0-9.3. After iOS10.0 it stopped working for an unknown reason. Is anybody facing this issue right now?

#pragma mark - Table view delegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return self.selectedIndexPath && self.selectedIndexPath.row == indexPath.row ? self.view.frame.size.height - self.navigationController.navigationBar.frame.size.height + 20 : UITableViewAutomaticDimension;
}

Inside the didSelect Method

if(shouldExpand){
        [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
            [self.tableView beginUpdates];
            [self.tableView endUpdates];
        } completion:nil];
}
else{
    [self.tableView beginUpdates];
    [self.tableView endUpdates];
}
Ashraf Tawfeeq
  • 3,036
  • 1
  • 20
  • 34
  • Update your question with relevant code. – rmaddy Sep 26 '16 at 14:39
  • Pretty basic nothing much going on. – Ashraf Tawfeeq Sep 26 '16 at 14:47
  • It's not an answer but more a suggestion: have you tried calling ```reloadRowsAtIndexPaths:withAnimation:``` in between ```beginUpdates``` and ```endUpdates```? – Fábio Oliveira Sep 27 '16 at 14:01
  • I have. But it animates with a fade effect not the desired stretch effect. – Ashraf Tawfeeq Sep 27 '16 at 15:18
  • else{ [self.tableView beginUpdates]; [self.tableView endUpdates]; } what do you expect to happen here , you should put ur code in between! – M_Waly Sep 27 '16 at 17:40
  • @M_Waly This code works perfectly on iOS 9+ – Ashraf Tawfeeq Sep 28 '16 at 07:59
  • Try to refresh the cell by simply calling: `[cell setNeedsLayout]`. Also check [this](http://stackoverflow.com/a/29763829/988169). – pkc456 Oct 05 '16 at 07:23
  • FYI, mine is working in iOS 10 but not in iOS 8 and 9. After using Xcode 8 it drives me crazy for whole day and I just removed all the animation-related codes. FYI [UIView animateWithDuration] in layoutSubviews() too also caused issues, but only running fine in iOS 10. I wonder who is working in Apple iOS department now... – felixwcf Nov 30 '16 at 09:52

2 Answers2

0

I have found that in iOS10.0 the change of the constraints of a superview is pretty much messed up for the subviews constraints. Filed a bug to Apple and waiting for there answer. Reported and here's a link

Ashraf Tawfeeq
  • 3,036
  • 1
  • 20
  • 34
0

I had the same issue. What I did was to call tableView.reloadData() (Because the cells are already there) after my .endUpdate() method is called (I have a delegate method, that informs me when this happens).

LyuboPrime
  • 3
  • 1
  • 1