Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/rust/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我应该能用这种方法检测到多指敲击吗?_Iphone_Multi Touch - Fatal编程技术网

Iphone 我应该能用这种方法检测到多指敲击吗?

Iphone 我应该能用这种方法检测到多指敲击吗?,iphone,multi-touch,Iphone,Multi Touch,这是已启用多个触摸的视图的touchesbearth方法 - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* touch = [touches anyObject]; if ([touches count] > 1) NSLog(@"multi touches: %d fingers", [touches count]); NSUInteger nu

这是已启用多个触摸的视图的touchesbearth方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch* touch = [touches anyObject];
    if ([touches count] > 1)
        NSLog(@"multi touches: %d fingers", [touches count]);

    NSUInteger numTaps = [touch tapCount];

    if (numTaps == 1) {
        NSLog(@"single tap");
    } else {
        NSLog(@"multi tap: %d", numTaps);
    }
}

我似乎从不记录多次触摸。只需单点和双点。我认为这和获取触摸次数一样简单是错误的吗?

您应该在视图中将
multipletouchedabled
属性设置为
YES
,让它向您发送多个
UITouch
对象

除此之外,只传递更改的
UITouch
对象。如果您触摸某个位置而不移动手指,然后触摸另一个位置,则只会传递新的触摸对象。您应该查询视图中所有活动触摸的
UIEvent
对象:

[event touchesForView:self]

您应该在视图中将
multipletouchedabled
属性设置为
YES
,以允许它向您发送多个
UITouch
对象

除此之外,只传递更改的
UITouch
对象。如果您触摸某个位置而不移动手指,然后触摸另一个位置,则只会传递新的触摸对象。您应该查询视图中所有活动触摸的
UIEvent
对象:

[event touchesForView:self]

我尝试了三种不同的方法,只有一种可以返回两到五个手指敲击。获胜机制为NSSet*touch=[event alltouch]

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch* touch = [touches anyObject];
    // the next line will not ever return a multiple tap
    if ([touches count] > 1)
        NSLog(@"multi-touches %d", [touches count]);
    // the next line will return up to 5 (verified) simultaneous taps (maybe more)
        NSSet *touch2 = [event allTouches];
    if ([touch2 count] > 1)
        NSLog(@"multi-touches2 %d", [touch2 count]);
    // the next line only returns 1 tap
        NSSet *touch3 = [event touchesForView:self];
    if ([touch3 count] > 1)
        NSLog(@"multi-touches2 %d", [touch3 count]);
}

我尝试了三种不同的方法,只有一种可以返回两到五个手指敲击。获胜机制为NSSet*touch=[event alltouch]

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
        UITouch* touch = [touches anyObject];
    // the next line will not ever return a multiple tap
    if ([touches count] > 1)
        NSLog(@"multi-touches %d", [touches count]);
    // the next line will return up to 5 (verified) simultaneous taps (maybe more)
        NSSet *touch2 = [event allTouches];
    if ([touch2 count] > 1)
        NSLog(@"multi-touches2 %d", [touch2 count]);
    // the next line only returns 1 tap
        NSSet *touch3 = [event touchesForView:self];
    if ([touch3 count] > 1)
        NSLog(@"multi-touches2 %d", [touch3 count]);
}

制胜机制?甚至没有被使用的错误和变量

不兼容的Objective-C类型“struct AViewController*”,在从不同的Objective-C类型传递“touchesForView:”的参数1时应为“struct UIView*”


AViewController.m:64:未使用的变量“touch”

制胜机制?甚至没有被使用的错误和变量

不兼容的Objective-C类型“struct AViewController*”,在从不同的Objective-C类型传递“touchesForView:”的参数1时应为“struct UIView*”


AViewController.m:64:未使用的变量“touch”

我刚刚添加了一个事实,即mutliple touch属性已启用(并且不起作用)。这不起作用。这是:NSSet*touch=[event alltouch];mahboudz:如果两个触摸都在特定视图中启动,那么它应该可以工作。当然,
self
,我指的是视图实例。我只是添加了一个事实,即mutliple touch属性已启用(但它不起作用)。这不起作用。这是:NSSet*touch=[event alltouch];mahboudz:如果两个触摸都在特定视图中启动,那么它应该可以工作。当然,
self
,我指的是视图实例。首先,获胜机制是“NSSet*touch=[event alltouch];“其次,你是定义自我的人。如果你自己不是一个UIView,那么不要责怪别人。最后,试着理解答案,而不是仅仅照搬它,期望它完全适合你的需要。你真的认为下面这个“touch”未使用的方法是生产代码吗?首先,获胜机制是“NSSet*touch=[event alltouch];“其次,你是定义自我的人。如果你自己不是一个UIView,那么不要责怪别人。最后,试着理解答案,而不是仅仅照搬它,期望它完全适合你的需要。你真的认为下面这个“touch”未使用的方法是生产代码吗?谢谢。只是澄清一下:[Touchs count]没有给出触摸次数,但是[[event AllTouchs]count]给出了。谢谢。只是想澄清一下:[Touchs count]没有给出触摸次数,但是[[event AllTouchs]count]给出了。