mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-14 02:10:15 +00:00
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:
parent
456dc8535d
commit
e18d1394e4
@ -51,6 +51,26 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
return __val; \
|
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 -
|
||||||
#pragma mark ASCellNode<->UITableViewCell bridging.
|
#pragma mark ASCellNode<->UITableViewCell bridging.
|
||||||
|
|
||||||
@ -1173,6 +1193,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
|
- (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
|
// If a scroll happenes the current range mode needs to go to full
|
||||||
ASInterfaceState interfaceState = [self interfaceStateForRangeController:_rangeController];
|
ASInterfaceState interfaceState = [self interfaceStateForRangeController:_rangeController];
|
||||||
if (ASInterfaceStateIncludesVisible(interfaceState)) {
|
if (ASInterfaceStateIncludesVisible(interfaceState)) {
|
||||||
@ -1192,6 +1216,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
|
- (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;
|
CGPoint contentOffset = scrollView.contentOffset;
|
||||||
_deceleratingVelocity = CGPointMake(
|
_deceleratingVelocity = CGPointMake(
|
||||||
contentOffset.x - ((targetContentOffset != NULL) ? targetContentOffset->x : 0),
|
contentOffset.x - ((targetContentOffset != NULL) ? targetContentOffset->x : 0),
|
||||||
@ -1210,6 +1238,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
|
||||||
{
|
{
|
||||||
|
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
|
||||||
|
[super scrollViewDidEndDecelerating:scrollView];
|
||||||
|
return;
|
||||||
|
}
|
||||||
_deceleratingVelocity = CGPointZero;
|
_deceleratingVelocity = CGPointZero;
|
||||||
|
|
||||||
if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
|
if (_asyncDelegateFlags.scrollViewDidEndDecelerating) {
|
||||||
@ -1219,6 +1251,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
|
||||||
{
|
{
|
||||||
|
if (scrollView != self && UITABLEVIEW_RESPONDS_TO_SELECTOR()) {
|
||||||
|
[super scrollViewWillBeginDragging:scrollView];
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
|
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
|
||||||
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventWillBeginDragging
|
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventWillBeginDragging
|
||||||
inScrollView:scrollView
|
inScrollView:scrollView
|
||||||
@ -1231,6 +1267,10 @@ static NSString * const kCellReuseIdentifier = @"_ASTableViewCell";
|
|||||||
|
|
||||||
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
|
- (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) {
|
for (_ASTableViewCell *tableViewCell in _cellsForVisibilityUpdates) {
|
||||||
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventDidEndDragging
|
[[tableViewCell node] cellNodeVisibilityEvent:ASCellNodeVisibilityEventDidEndDragging
|
||||||
inScrollView:scrollView
|
inScrollView:scrollView
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user