UITableView Scroll event

前端 未结 3 1445
渐次进展
渐次进展 2020-11-29 09:12

I want to detect if mytable view has been scrolled, I tried all touch events like this one:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
         


        
3条回答
  •  难免孤独
    2020-11-29 09:27

    If you have more than one table views as asked by Solidus, you can cast the scrollview from the callback to tableview as UITableView is derived from UIScrollView and then compare with the tableviews to find the source tableview.

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView {    
            UITableView* fromTableView = (UITableView*) scrollView;
            UITableView* targetTableView = nil;
            if (fromTableView == self.leftTable) {
                targetTableView = self.leftTable;
            } else {
                targetTableView = self.rightTable;
            }
    ...
    }
    

提交回复
热议问题