https://github.com/queeniecplusplus/ios_back_4
Gyro
https://github.com/queeniecplusplus/ios_back_4
coremotion-sensors gyroscope ios11 ios14 swift4 swift5 xcode11 xcode12
Last synced: about 1 month ago
JSON representation
Gyro
- Host: GitHub
- URL: https://github.com/queeniecplusplus/ios_back_4
- Owner: QueenieCplusplus
- Created: 2021-01-27T07:17:18.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-01-27T07:21:43.000Z (about 5 years ago)
- Last Synced: 2025-03-13T13:13:45.599Z (11 months ago)
- Topics: coremotion-sensors, gyroscope, ios11, ios14, swift4, swift5, xcode11, xcode12
- Language: Swift
- Homepage: https://github.com/QueenieCplusplus/QuickGoThru#apple-ios-swift-溫故愛鳳---計畫復甦
- Size: 1.95 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# iOS_Back_4
Gyro
1. code in ViewController.
//
// 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()
}
}