iphone - 无法检索同时触摸的数量

标签 iphone ios objective-c ipad uiview

在我的 UIView 子类中我有这个:

- (void) touchesBegan: (NSSet*) touches withEvent: (UIEvent*) event
{
    UITouch* touch = [touches anyObject];
    CGPoint location  = [touch locationInView: self];
    NSLog(@"touches count: %i",[touches count]); //always shows 1
}

无论我用多少根手指触摸屏幕,我都只会得到“1”作为输出。我还将上面的内容添加到 touchesMoved 中,结果相同。

最佳答案

您是否启用了多点触控选项?

[(your uiview) setMultiTouchEnabled:YES];

默认情况下为 false,这会将您 View 上的所有触摸转换为所有其他触摸中间的一次触摸。

将它设置为 YES 将使您的 View 接收屏幕上每个手指(或笔)的一次触摸事件

关于iphone - 无法检索同时触摸的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14750216/

相关文章:

ios - 一种UIView动画取消了iOS中的另一种动画

iphone - 当前ModalViewController : how to interact with parent

ios - 使用单个 XIB 和类创建多个 Collection View 单元

ios - 您的二进制文件未针对 iPhone 5 进行优化

ios - 单点触摸错误: mtouch exited with code 1

ios - scrollToRowAtIndexPath 没有正确处理最后一行

iphone - 如何确定用户在从我的应用调用电话时是否按下了“调用”或“取消”按钮?

iphone - 在 obj-c 中使用正则表达式在字符串中搜索模式

iPhone - 即使用户的位置服务打开,LocationManager 也不会收敛?

iphone - 黑色半透明导航栏 + MKMapView -> 设置 map 中心在视觉上不正确