【问题标题】:Multi-touch is not working in the iphone app I'm building多点触控在我正在构建的 iphone 应用程序中不起作用
【发布时间】:2010-10-10 10:41:02
【问题描述】:

我有以下代码:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {


NSUInteger touchCount = 0;
// Enumerates through all touch objects
for (UITouch *touchb in touches){
    touchCount++;
}


// When multiple touches, report the number of touches. 
if (touchCount > 1) {
    lblStatustouch.text = [NSString stringWithFormat:@"Tracking %d touches", touchCount];
} else {
    lblStatustouch.text = [NSString stringWithFormat:@"Tracking 1 touch", touchCount];
}

当我运行它时,它从不检测超过一次触摸。是否有一些设置可能会阻止我的应用程序进行多次触摸?还是我在这里遗漏了什么?

【问题讨论】:

    标签: iphone objective-c ipod-touch


    【解决方案1】:

    您需要在 InterfaceBuilder 中的视图上启用“多点触控”

    alt text http://img.skitch.com/20090227-rpkafsxtg56pujk1h1583if88i.jpg

    或者,如果您已经在代码中创建了视图,则使用它设置

    [theView setMultipleTouchEnabled:YES];
    

    【讨论】:

    • 谢谢,我在代码中创建了视图,并试图弄清楚它。我做到了,现在效果很好!
    • Bryan,如果这是正确答案,您应该通过单击答案左侧的绿色小复选标记“接受”它。
    【解决方案2】:

    还知道,如果两个手指同时移动,您只会在 touchesMoved 中获得多次触摸。如果您将一根手指固定在屏幕上,然后移动另一根手指,手机只会报告正在移动的手指。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 2022-08-17
      • 2019-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多