Multitouch tracking issue

后端 未结 2 1118
有刺的猬
有刺的猬 2020-12-11 22:40

I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user rights, I followed this link How

相关标签:
2条回答
  • 2020-12-11 22:58

    If I understood your problem correctly, you're having undesired strokes whenever the user uses multiple fingers on your canvas. Since you already have a self.trackingTouch, will it be reasonable to just ignore every other touch that is not self.trackingTouch?

    -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    {
        if (self.trackingTouch)
        {
            // another touch is active so we ignore this one
            return;
        }
        // ...the rest of your code
    }
    
    -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = self.trackingTouch;
        if (![touches containsObject:touch])
        {
            // updates to touches other than self.trackingTouch
            return;
        }
    
        // ...process only self.trackingTouch in the rest of your code
    }
    
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
    {
        UITouch *touch = self.trackingTouch;
        if (![touches containsObject:touch])
        {
            // updates to touches other than self.trackingTouch
            return;
        }
    
        // ...process only self.trackingTouch in the rest of your code
    
       self.trackingTouch = nil;
    }
    
    -(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
    {
        // ...same as touchesEnded:withEvent:
    }
    
    0 讨论(0)
  • 2020-12-11 23:00

    You will need to debug to confirm, but it appears to be related to your logic in touchesBegan:withEvent:. In this method, you check each time there is a new touch to determine if it is the 'highest', but when the highest touch does actually change you don't seem to abort / reset any existing drawing.

    Your best approach is probably using logging to determine if / when the 'highest' touch is changing and what affect that has on the in-progress line.

    Also, in touchesMoved:, you don't need the for (UITouch *touch in touches) loop as you already have a reference to self.trackingTouch so you can just use it directly.

    0 讨论(0)
提交回复
热议问题