ios*_*ard 9 touch touchesmoved touch-event ios uievent
我有一个子类UIView上的顶部UITableView.我正在使用它UITableView来显示一些数据,同时,我想覆盖手指后面的动画(例如,留下一条线索).
如果我是正确的,我需要的触摸事件要处理两个由UIView子和UITableView.我怎样才能做到这一点?是否可以touchesMoved在UIView子类上触发,然后再触发UITableView?
非常感谢你的帮助.
ios*_*ard 11
我解决这个问题的方式是不是那么干净,但它有效.如果有更好的方法,请告诉我.
我已经覆盖hitTest了我的自定义,UIView因此它将触摸指向UITableView下方.然后在UITableView我处理过的姿势touchesBegan,touchesMoved等有我也呼吁touchesBegan对UIView.
这样,触摸由两个视图处理.我为什么不这样做的其他方式的原因(具有UIView的touchesBegan调用UITableView的touchesBegan)是在手势识别UITableView是行不通的.
UIView 子类 hitTest
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
// tview is the UITableView subclass instance
CGPoint tViewHit = [tView convertPoint:point fromView:self];
if ([tView pointInside:tViewHit withEvent:event]) return tView;
return [super hitTest:point withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
UITableView 子类的 touchesBegan
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:touch.view];
// ....
// view is the UIView's subclass instance
[view touchesBegan:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14960 次 |
| 最近记录: |