Fix issue with swipe to delete cell gesture. (#46)

Ensure superclass scroll view delegate methods are called when the scroll view parameter is not the current ASTableView.
This commit is contained in:
rewcraig 2017-04-29 15:54:00 -07:00 committed by Adlai Holler
parent 456dc8535d
commit e18d1394e4

View File

@ -51,6 +51,26 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
return __val; \
}
#define UITABLEVIEW_RESPONDS_TO_SELECTOR() \
({ \
static BOOL superResponds; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
superResponds = [UITableView instancesRespondToSelector:_cmd]; \
}); \
superResponds; \
})
@interface UITableView (ScrollViewDelegate)
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
@end
#pragma mark -
#pragma mark ASCellNode<->UITableViewCell bridging.
@ -1173,6 +1193,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidScroll:scrollView];
return;
}
// If a scroll happenes the current range mode needs to go to full
ASInterfaceState interfaceState = [self interfaceStateForRangeController:_rangeController];
if (ASInterfaceStateIncludesVisible(interfaceState)) {
@ -1192,6 +1216,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewWillEndDragging:scrollView withVelocity:velocity targetContentOffset:targetContentOffset];
return;
}
CGPoint contentOffset = scrollView.contentOffset;
_deceleratingVelocity = CGPointMake(
contentOffset.x - ((targetContentOffset != NULL) ? targetContentOffset->x : 0),
@ -1210,6 +1238,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidEndDecelerating:scrollView];
return;
}
_deceleratingVelocity = CGPointZero;
if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
@ -1219,6 +1251,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewWillBeginDragging:scrollView];
return;
}
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventWillBeginDragging
inScrollView:scrollView
@ -1231,6 +1267,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
[super scrollViewDidEndDragging:scrollView willDecelerate:decelerate];
return;
}
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventDidEndDragging
inScrollView:scrollView