小编Moo*_*r4z的帖子

Swift陀螺仪偏航,俯仰,滚动

我正在为我的学校做一个项目,为一个编程主题.我在Swift的Xcode工作.我想制作一个使用陀螺仪的应用程序.我不知道但不知何故它不会在我的iphone上运行因为Xcode中的一些错误我不知道如何修复.当我运行该程序时说"致命错误:在解开一个Optional值时意外发现nil (lldb)"我的项目的主要内容是使用陀螺仪在iphone屏幕上以度为单位显示旋转(偏转,俯仰,滚动).如果有人帮助我,我将非常感激.先感谢您.

我的ViewController中的代码:

import UIKit
import CoreMotion

class ViewController: UIViewController {

    var currentMaxRotX: Double = 0.0
    var currentMaxRotY: Double = 0.0
    var currentMaxRotZ: Double = 0.0

    let motionManager = CMMotionManager()

    @IBOutlet var rotX : UILabel! = nil
    @IBOutlet var rotY : UILabel! = nil
    @IBOutlet var rotZ : UILabel! = nil

    @IBOutlet var maxRotX : UILabel! = nil
    @IBOutlet var maxRotY : UILabel! = nil
    @IBOutlet var maxRotZ : UILabel! = nil


    @IBOutlet weak var RollLabel: UILabel! = nil

    @IBOutlet …
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios core-motion swift

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

core-motion ×1

ios ×1

iphone ×1

swift ×1

xcode ×1