Delay with touch events

前端 未结 4 385
逝去的感伤
逝去的感伤 2021-01-14 22:36

We have an app in AppStore Bust~A~Spook we had an issue with. When you tap the screen we use CALayer to find the position of all the views during their animation and if you

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-14 23:03

    This is a pretty old post about a seasonal app, so the OP probably isn't still working on this problem, but in case others come across this same problem and find this useful.

    I agree with Kriem that CPU overload is a common cause of significant delay in touch processing, though there is a lot of optimization one can do before having to pull out OpenGL. CALayer is quite well optimized for the kinds of problems you're describing here.

    We should first check the basics:

    • CALayers added to the main view's layer
    • touchesBegan:withEvent: implemented in the main view
    • When the phase is UITouchPhaseBegan, you call hitTest: on the main view's layer to find the appropriate sub-layer
    • Die sequence starts on the relevant model object, updating the layer.

    Then, we can check performance using Instruments. Make sure your CPU isn't overloaded. Does everything run fine in simulator but have trouble on the device?

    The problem you're trying to solve is very common, so you should not expect a complex or tricky solution to be required. It is most likely that the design or implementation has a basic flaw and just needs troubleshooting.

提交回复
热议问题