Swift / MotionKit.framework / 如何更新标签

Swift / MotionKit.framework / how to update label

我正在尝试利用运动数据。我使用 MotionKit Framework 创建了一个测试应用程序。 print(testString) 以一秒为间隔将 x 变量正确打印到控制台。但是我的testLabel不会更新一次。

import UIKit
import MotionKit

class ViewController: UIViewController {

@IBOutlet weak var testLabel: UILabel!

let motionKit = MotionKit()

override func viewDidLoad() {
    super.viewDidLoad()

    motionKit.getAccelerometerValues(1.0) { (x, y, z) -> () in
        let testString = String(x)
        self.testLabel.text = testString
        print(testString)            
    }
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}
}

我错过了什么?非常感谢帮助。

只需将您的文本字段文本代码包装在 dispatch_async

dispatch_async(dispatch_get_main_queue(), ^{ 
      self.testLabel.text = testString  
    });