iphone应用程序I';m大厦

iphone应用程序I';m大厦,iphone,objective-c,ipod-touch,Iphone,Objective C,Ipod Touch,我有以下代码: - (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 tou

我有以下代码:

- (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];
}
当我运行它时,它从未检测到超过一次触摸。是否有一些设置可能会阻止我的应用进行多次触摸?还是我在这里遗漏了什么?

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

或者,如果您已经在代码中创建了视图,那么它将使用

[theView setMultipleTouchEnabled:YES];

还要知道,如果两个手指同时移动,则只能在TouchsMoved中进行多次触摸。如果您在屏幕上固定了一根手指,并移动了另一根手指,手机将只报告正在移动的手指。

谢谢,我用代码创建了视图,并且正在疯狂地尝试解决它。我做到了,现在效果很好!布莱恩,如果这是正确的答案,你应该通过点击答案左边的绿色小复选标记来“接受”它。