小编Kis*_*ial的帖子

检测UITableView滚动

我已经将UITableView(作为KRTableView)子类化并实现了四种基于触摸的方法(touchesBegan,touchesEnded,touchesMoved和touchesCancelled),以便我可以检测何时在UITableView上处理基于触摸的事件.基本上我需要检测的是当UITableView向上或向下滚动时.

但是,子类化UITableView并创建上述方法只能检测UITableViewCell内的滚动或手指移动,而不是整个UITableView.

一旦我的手指移动到下一个单元格,触摸事件就不会做任何事情.

这就是我为UITableView创建子类的方法:

#import "KRTableView.h"


@implementation KRTableView

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesBegan:touches withEvent:event];   
    NSLog(@"touches began...");
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesMoved:touches withEvent:event];
  NSLog(@"touchesMoved occured");   
}

- (void)touchesCancelled:(NSSet*)touches withEvent:(UIEvent *)event {
    [super touchesCancelled:touches withEvent:event];
  NSLog(@"touchesCancelled occured");   
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
  [super touchesEnded:touches withEvent:event];
  NSLog(@"A tap was detected on KRTableView");
}

@end
Run Code Online (Sandbox Code Playgroud)

如何检测UITableView何时向上或向下滚动?

iphone cocoa-touch objective-c uitableview

56
推荐指数
2
解决办法
6万
查看次数

你如何在Swift中导入Metal?

每当我尝试使用import Metal我的Swift文件或游乐场时,Xcode都说"没有这样的模块'金属'".这是Beta 1错误吗?

xcode swift ios8 metal

8
推荐指数
1
解决办法
7426
查看次数

标签 统计

cocoa-touch ×1

ios8 ×1

iphone ×1

metal ×1

objective-c ×1

swift ×1

uitableview ×1

xcode ×1