- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch=[touches anyObject];
if (![self pointInside:[touch locationInView:self] withEvent:nil]) {
NSLog(@"touches moved outside the view");
}else {
UIView *hitView=[self hitTest:[[touches anyObject] locationInView:self] withEvent:nil];
if (hitView==self) {
NSLog(@"touches moved in the view");
}else{
NSLog(@"touches moved in the subview");
}
}
}
UITouch *touch=[touches anyObject];
if (![self pointInside:[touch locationInView:self] withEvent:nil]) {
NSLog(@"touches moved outside the view");
}else {
UIView *hitView=[self hitTest:[[touches anyObject] locationInView:self] withEvent:nil];
if (hitView==self) {
NSLog(@"touches moved in the view");
}else{
NSLog(@"touches moved in the subview");
}
}
}
本文探讨了在视图内部与外部触摸移动事件的处理机制,通过实例展示了如何区分触摸事件发生的区域,并根据不同情况采取相应的操作。
736

被折叠的 条评论
为什么被折叠?



