How to effectively process UITouches in a multitouch sequence

我的未来我决定 提交于 2019-11-27 15:52:38

Assuming the drawing code is all the same the difference is only the extra overhead of processing the extra touches. Looping to process these, looping to draw, everything is at least doubled.. So while you are processing touch and then drawing on finger #2, out here in the real world finger #1 etc is/are still moving... Be mindful that UIKit can only draw at the end of each runLoop. I don't think there is any way around this, also as I told you before, I doubt there are many people who will value the ability to draw with multiple touches, although this may well be my limited, English speaking, Australian perspective on it. Good luck

I finally solved my issue,

Here is the code

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch* topmostTouch = self.trackingTouch;
    for (UITouch *touch in touches)
    {


        touchStartPoint1 = [touch locationInView:self];


        if(!topmostTouch || [topmostTouch locationInView:self].y > touchStartPoint1.y)
        {
            ctr = 0;
            topmostTouch = touch;
            pts[0] = touchStartPoint1;
        }
    }   

    self.trackingTouch = topmostTouch;
}

The problem was very simple, just set ctr = 0 , inside the check, like this..

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!