Detect shake gesture IOS Swift

后端 未结 8 2156
难免孤独
难免孤独 2020-12-08 02:27

I\'m developing a app with a gesture system, basically if I turn the iPhone to left my app will do a function, if I turn the iPhone to Right, other function, with others ges

8条回答
  •  一向
    一向 (楼主)
    2020-12-08 03:06

    This has been updated for IOS 12 - see Apple Docs You no longer need to add becomeFirstResponder() method.

    You just need to add motionEnded function to your code.

    override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) 
    {
        // code here
    }
    

提交回复
热议问题