Swift 3.0 how to use startDeviceMotionUpdates(to: withHandler)?

本小妞迷上赌 提交于 2019-12-10 09:27:28

问题


Swift 3.0 was released alongside Xcode 8.0 and apparently a lot has changed. I'm very unfamiliar with the new syntax in swift. Can someone help me out? I'm trying to figure out what goes in

motionManager.startDeviceMotionUpdates(
        to: OperationQueue.current()!,
        withHandler: )

after the "withHandler:"

I am trying to get my SceneKit program be able to utilize the accelerometer to determine the orientation of an SCNNode platform. I am also fairly new to swift (about 5 days into programming in Swift) so if there's something fundamental I am messing up, let me know.


回答1:


Reference

You must pass the block that conforms the CMDeviceMotionHandler type.

 motionManager.startDeviceMotionUpdates(to: OperationQueue.current()!, withHandler:{
                deviceManager, error in
                //Do stuffs with deviceManager or with error

            })


来源:https://stackoverflow.com/questions/37850229/swift-3-0-how-to-use-startdevicemotionupdatesto-withhandler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!