A count of started touches is not equal to count of finished touches

后端 未结 5 2091
无人共我
无人共我 2021-02-07 10:10

I have the following code for testing purposes:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [self customTouchHandler:touches];
}

- (v         


        
5条回答
  •  梦毁少年i
    2021-02-07 10:27

    If you are using more than one finger you should include self.view.multipleTouchEnabled = YES; in your init.

    I ran some extensive tests on your supplied code and the only time the numbers do not match up is when the taping occurs very fast from a combination of either one or both fingers. In this case, iOS looses track of the contact the current state.

    This is very similar to when a sprite bounces up and down very quickly on another sprite which sometimes causes a wrong contact state in the didBeginContact.

    There is currently no way you can get around this using multiple touches. If you use a single touch, your count will always (at least in my tests) match.

提交回复
热议问题