31
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【iOS】【swift】加速度センサー CMMotionManager

Last updated at Posted at 2014-10-27

CMMotionManagerの基礎的な動きを。

まずは、importを


import CoreMotion

次に、


manager = CMMotionManager()
//取得の間隔
manager.accelerometerUpdateInterval = 0.01;
let handler:CMAccelerometerHandler = {(data:CMAccelerometerData!, error:NSError!) -> Void in
            println(data.acceleration.x)
            println(data.acceleration.y)
            println(data.acceleration.z)

        }

//取得開始
manager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler:handler)


停止について


if (manager.accelerometerActive) {
    manager.stopAccelerometerUpdates()
}

ジャイロなどについてもまとめれば。。

31
30
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?