相关疑难解决方法(0)

如何向UIView添加触摸事件?

如何向UIView添加触摸事件?
我尝试:

UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, nextY)] autorelease];
[headerView addTarget:self action:@selector(myEvent:) forControlEvents:UIControlEventTouchDown];
// ERROR MESSAGE: UIView may not respond to '-addTarget:action:forControlEvents:'
Run Code Online (Sandbox Code Playgroud)

我不想创建子类和覆盖

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
Run Code Online (Sandbox Code Playgroud)

events objective-c touch uiview ios

272
推荐指数
9
解决办法
32万
查看次数

在UIView上触摸事件

有没有人有任何示例代码来检测动态创建的UIView上的触摸?我找到了一些touchesBegan的引用,但无法弄清楚如何实现它...

iphone objective-c uikit ios

30
推荐指数
3
解决办法
8万
查看次数

标签 统计

ios ×2

objective-c ×2

events ×1

iphone ×1

touch ×1

uikit ×1

uiview ×1