【发布时间】:2014-02-06 17:54:48
【问题描述】:
几周以来,我一直在努力解决多点触控“手指跟踪”问题。我的背景是硬件和嵌入式系统编程,所以我对微控制器编程以外的任何东西都没有经验。我取得了一些成功,但只有当多个触摸同时开始和结束时。我的项目是音频硬件的手势控制界面,所以我需要跟踪每次触摸以产生自定义手势。
这个例子展示了我如何从 [touches allObjects] 中提取每个触摸以便单独处理它们(我排除了处理代码,这对这个例子来说是多余的)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
touchesArray = [touches allObjects]; //Array Declared in header to hold multiple touches.
NSUInteger nNumTouches = [touchesArray count]; //Counts number of touches in Array
UITouch *touch = [touches anyObject];
CGPoint ptTouch;
for (int nTouch = 0; nTouch < nNumTouches; nTouch++)
{
touch = [touchesArray objectAtIndex:nTouch];
ptTouch = [touch locationInView:self.view];
{
是否有更有效的方法来跟踪每次触摸?我觉得我的编程知识已经走到了尽头。尤其是在尝试操作 NSMutable 数组无效之后。我也已阅读,但未能从此处执行详细信息:https://developer.apple.com/library/ios/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/multitouch_background/multitouch_background.html#//apple_ref/doc/uid/TP40009541-CH5-SW9
对此的回应看起来很有趣,但我无法让它在上下文中发挥作用:
how to track multitouch events on iphone?
感谢您的宝贵时间,任何建议将不胜感激,
汤姆。
【问题讨论】:
标签: ios iphone objective-c