From 78e51782ca4f3078c7080dc322fce5a88f73f12e Mon Sep 17 00:00:00 2001 From: Little_Player Date: Tue, 22 May 2018 14:31:54 +0800 Subject: [PATCH] fix bug: if call "-(void)setRightUtilityButtons: WithButtonWidth:" to change the buttonWidth while scrollView is still scrolling, scrollView's contentOffset will be wrong. --- SWTableViewCell/PodFiles/SWTableViewCell.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/SWTableViewCell/PodFiles/SWTableViewCell.m b/SWTableViewCell/PodFiles/SWTableViewCell.m index 3daceac..143602d 100644 --- a/SWTableViewCell/PodFiles/SWTableViewCell.m +++ b/SWTableViewCell/PodFiles/SWTableViewCell.m @@ -757,6 +757,11 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { [self updateCellState]; + // if call "-(void)setRightUtilityButtons: WithButtonWidth:" to change the buttonWidth while scrollView is still scrolling, scrollView's contentOffset will be wrong. + CGPoint contentOffset = [self contentOffsetForCellState:_cellState]; + if (!CGPointEqualToPoint(self.cellScrollView.contentOffset, contentOffset)) { + self.cellScrollView.contentOffset = contentOffset; + } if (self.delegate && [self.delegate respondsToSelector:@selector(swipeableTableViewCellDidEndScrolling:)]) { [self.delegate swipeableTableViewCellDidEndScrolling:self];