Swift 3.0如何使用startDeviceMotionUpdates(to:withHandler)? [英] Swift 3.0 how to use startDeviceMotionUpdates(to: withHandler)?

查看:76
本文介绍了Swift 3.0如何使用startDeviceMotionUpdates(to:withHandler)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Swift 3.0与Xcode 8.0一起发布,显然发生了很多变化.我很快不熟悉新语法.有人可以帮我吗?我正在尝试弄清楚到底是怎么回事

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: )

"withHandler:"之后

after the "withHandler:"

我正在尝试使我的SceneKit程序能够利用加速度计来确定SCNNode平台的方向.我也是新手,很快(大约需要花5天的时间在Swift中进行编程),所以如果有一些基本问题我要弄乱了,请告诉我.

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.

推荐答案

您必须传递符合CMDeviceMotionHandler类型的块.

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

            })

这篇关于Swift 3.0如何使用startDeviceMotionUpdates(to:withHandler)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆