【问题标题】:Swift 3.0 how to use startDeviceMotionUpdates(to: withHandler)?Swift 3.0 如何使用 startDeviceMotionUpdates(to: withHandler)?
【发布时间】:2016-10-17 10:36:16
【问题描述】:

Swift 3.0 与 Xcode 8.0 一起发布,显然发生了很多变化。我对swift中的新语法非常陌生。有人可以帮我吗?我试图弄清楚发生了什么

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

在“withHandler:”之后

我试图让我的 SceneKit 程序能够利用加速度计来确定 SCNNode 平台的方向。我对 Swift 也很陌生(使用 Swift 编程大约 5 天),所以如果有什么基本的东西我搞砸了,请告诉我。

【问题讨论】:

    标签: scenekit core-motion swift3 xcode8 ios10


    【解决方案1】:

    Reference

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

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

    【讨论】:

    • 是的,我正要自己回答这个问题,因为我刚刚想通了,顺便谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多