Swift: how to disable user interaction while touch action is being carried out?

后端 未结 8 2432
执念已碎
执念已碎 2021-02-12 03:27

I\'m working with sprite kit and if the user touches the screen, the actions within

override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
            


        
相关标签:
8条回答
  • 2021-02-12 04:27

    To disable user interaction app-wide, use:

    UIApplication.shared.beginIgnoringInteractionEvents()
    UIApplication.shared.endIgnoringInteractionEvents()
    

    (as of Swift 5 this is deprecated)

    0 讨论(0)
  • 2021-02-12 04:28

    Try to get the view from the touch object and then dissable the user interaction on it.

    touch.view.isUserInteractionEnabled = false
    
    0 讨论(0)
提交回复
热议问题