[英]Multi-touch is not working in the iphone app I'm building
I have the following code: 我有以下代码:
- (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];
}
When I run it, it never detects more than one touch. 当我运行它时,它永远不会检测到多个触摸。 Is there some setting that may prevent my app from taking multiple touches?
是否有一些设置可能会阻止我的应用进行多次触摸? Or am I missing something here?
或者我在这里遗漏了什么?
You need to enable "Multiple Touch" on your View in InterfaceBuilder 您需要在InterfaceBuilder中的View上启用“Multiple Touch”
alt text http://img.skitch.com/20090227-rpkafsxtg56pujk1h1583if88i.jpg 替代文字http://img.skitch.com/20090227-rpkafsxtg56pujk1h1583if88i.jpg
or if you have created the View in code it's set with 或者,如果您在代码中创建了视图,则设置为
[theView setMultipleTouchEnabled:YES];
Also know that you will only get multiple touches in touchesMoved if both fingers are moving at the same time . 也知道,你只会得到多点触摸在touchesMoved如果两个手指同时移动。 If you have a single finger fixed on the screen, and move a second finger around, the phone will only report the finger that is moving.
如果您的单个手指固定在屏幕上,并且再次移动第二根手指,则手机将仅报告正在移动的手指。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.