ios - Swift / MotionKit.framework / how to update label -
i'm trying exploit motion data. i've created test app using motionkit framework. print(teststring)
prints x
variables correctly console in 1 second interval. testlabel not updated once.
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() } }
what missing? appreciated.
just wrap textfield text code in dispatch_async
dispatch_async(dispatch_get_main_queue(), ^{ self.testlabel.text = teststring });
Comments
Post a Comment