cancelsTouchesInView

3 篇文章 0 订阅
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"touchesBegan");
}

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

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    NSLog(@"touchesEnded");
}

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

- (IBAction)panGestureRecognizerDidUpdate:(UIPanGestureRecognizer *)sender {
    NSLog(@"panGesture");
}

当然泛笔势识别器被配置为发送 panGestureRecognizerDidUpdate: 消息。

现在假设你碰认为,移动你的手指够泛手势必须承认,,然后抬起手指。这款应用程序的打印是什么?

如果笔势识别器有 cancelsTouchesInView 设置为 YES ,这款应用程序将这些消息记录:

touchesBegan
touchesMoved
touchesCancelled
panGesture
panGesture
(etc.)

你可能会得到多个 touchesMoved 之前取消。

所以,如果你设置 cancelsTouchesInView 到 YES (默认值),在它从笔势识别器,发送的第一个消息,您就不会在那触摸会更触摸相关的任何消息,你将会得到之前,系统将取消触摸。

如果笔势识别器有 cancelsTouchesInView 设置为 NO ,这款应用程序将这些消息记录:

touchesBegan
touchesMoved
panGesture
touchesMoved
panGesture
touchesMoved
panGesture
(etc.)
panGesture
touchesEnded

所以,如果你设置 cancelsTouchesInView 到 NO ,系统将继续发送手势触摸,与笔势识别器消息交错的触摸相关消息。触摸将正常结束而不是被取消 (除非系统取消触摸一些其他原因,像被触摸过程中按下首页按钮)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值