-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewController.swift
More file actions
37 lines (27 loc) · 846 Bytes
/
ViewController.swift
File metadata and controls
37 lines (27 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// ViewController.swift
// KatesGyroApp
//
// Created by KatesAndroid on 2021/1/27 PM 3:05
//
import UIKit
import CoreMotion
class ViewController: UIViewController {
let cmmm = CMMotionManager()
override func viewDidLoad() {
super.viewDidLoad()
// after nib.
//cmmm.startGyroUpdates(to: <#T##OperationQueue#>, withHandler: <#T##CMGyroHandler##CMGyroHandler##(CMGyroData?, Error?) -> Void#>)
cmmm.startGyroUpdates(to: OperationQueue()){
(data, error) in
if let data = data{
let tmp = data.rotationRate
print("(x, y, z) = (\(tmp.x), \(tmp.y), \(tmp.z)")
}
}
//cmmm.stopGyroUpdates()
}
override func viewWillDisappear(_ animated: Bool) {
cmmm.stopGyroUpdates()
}
}