@@ -138,11 +138,12 @@ @implementation SWUtilityButtonTapGestureRecognizer
138138
139139@interface SWTableViewCell () <UIScrollViewDelegate> {
140140 SWCellState _cellState; // The state of the cell within the scroll view, can be left, right or middle
141+ BOOL _isHidingUtilityButtons;
141142 CGFloat additionalRightPadding;
142143}
143144
144145// Scroll view to be added to UITableViewCell
145- @property (nonatomic , weak ) UIScrollView *cellScrollView;
146+ @property (nonatomic , strong ) SWCellScrollView *cellScrollView;
146147
147148// The cell's height
148149@property (nonatomic ) CGFloat height;
@@ -223,6 +224,7 @@ - (void)initializer {
223224 cellScrollView.delegate = self;
224225 cellScrollView.showsHorizontalScrollIndicator = NO ;
225226 cellScrollView.scrollsToTop = NO ;
227+ cellScrollView.scrollEnabled = YES ;
226228
227229 UITapGestureRecognizer *tapGesutreRecognizer = [[UITapGestureRecognizer alloc ] initWithTarget: self action: @selector (scrollViewUp: )];
228230 [cellScrollView addGestureRecognizer: tapGesutreRecognizer];
@@ -407,7 +409,11 @@ - (void)leftUtilityButtonHandler:(id)sender {
407409
408410- (void )hideUtilityButtonsAnimated : (BOOL )animated {
409411 // Scroll back to center
410- [self .cellScrollView setContentOffset: CGPointMake ([self leftUtilityButtonsWidth ], 0 ) animated: animated];
412+
413+ // Force the scroll back to run on the main thread because of weird scroll view bugs
414+ dispatch_async (dispatch_get_main_queue (), ^{
415+ [self .cellScrollView setContentOffset: CGPointMake ([self leftUtilityButtonsWidth ], 0 ) animated: YES ];
416+ });
411417 _cellState = kCellStateCenter ;
412418
413419 if ([_delegate respondsToSelector: @selector (swippableTableViewCell:scrollingToState: )]) {
@@ -427,6 +433,7 @@ - (void)layoutSubviews {
427433 self.scrollViewButtonViewLeft .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 , [self leftUtilityButtonsWidth ], _height);
428434 self.scrollViewButtonViewRight .frame = CGRectMake (CGRectGetWidth (self.bounds ), 0 , [self rightUtilityButtonsWidth ], _height);
429435 self.scrollViewContentView .frame = CGRectMake ([self leftUtilityButtonsWidth ], 0 , CGRectGetWidth (self.bounds ), _height);
436+ self.cellScrollView .scrollEnabled = YES ;
430437 self.containingTableView .scrollEnabled = YES ;
431438 self.tapGestureRecognizer .enabled = YES ;
432439}
@@ -552,6 +559,7 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
552559 self.scrollViewButtonViewLeft .frame = CGRectMake (scrollView.contentOffset .x , 0 .0f , [self leftUtilityButtonsWidth ], _height);
553560 }
554561 } else {
562+ self.containingTableView .scrollEnabled = YES ;
555563 [scrollView setContentOffset: CGPointMake ([self leftUtilityButtonsWidth ], 0 ) animated: NO ];
556564 }
557565}
@@ -565,6 +573,7 @@ - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
565573 // Called when setContentOffset in hideUtilityButtonsAnimated: is done
566574 self.tapGestureRecognizer .enabled = YES ;
567575 if (_cellState == kCellStateCenter ) {
576+ self.containingTableView .scrollEnabled = YES ;
568577 self.longPressGestureRecognizer .enabled = YES ;
569578 }
570579}
0 commit comments