我想检测mytable视图是否已被滚动,我try 了以下所有touch 事件:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  {
    [super touchesBegan:touches withEvent:event];
    //my code
  }

但似乎所有的touch 事件都不会对滚动做出react ,但它们只会在细胞被touch 、移动时做出react ,...等

有没有办法检测UITableView的滚动事件?

推荐答案

如果实现UITableViewDelegate协议,还可以实现UIScrollViewDelegate种方法之一:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

F或 example, if you have a property called tableView:

// ... setting up the table view here ...
self.tableView.delegate = self;
// ...

// Somewhere in your implementation file:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@"Will begin dragging");
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"Did Scroll");
}

This is because UITableViewDelegate conf或ms to UIScrollViewDelegate, as can be seen in the documentation 或 in the header file.

Objective-c相关问答推荐

如何在 NSImage CIFilter ObjC 周围创建边框

iOS:警告try 呈现其视图不在窗口层次 struct 中的 ViewController

如何使用第一个字符作为部分名称

我需要在 ARC 中使用 dealloc 方法吗?

如何处理 Xcode 警告没有以前的函数原型......?

UITableView 无限滚动

xcode 未知类型名称

如何在 XCode 4 中创建 dSYM 文件?

如何构建一个 Objective-C 静态库?

如何在另一个视图中获取视图的框架?

Container View 好像有 UINavigationBar 一样被下推?

UICollectionView 标头未显示

通过 ObjC 类别覆盖方法并调用默认实现?

iOS NSLayoutConstraint 使用 constraintWithItem 固定宽度

使用情节提要的条件转场

从 NSMutableString 中删除最后一个字符

Xcode 7 警告:目标文件是为比链接更新的 iOS 版本构建的

当 UIView 框架更改时,视图内的 AVPlayer 层不会调整大小

最大 CGFloat 值是否有常数?

iOS中的活动生命周期相当于什么?