<p>简单实现一些传感器</p>
import UIKit
import CoreMotion
import CoreLocation
class ViewController: UIViewController,CLLocationManagerDelegate {
@IBOutlet weak var compassView: UIView!
var cmm : CMMotionManager!
var queue : NSOperationQueue!
var locationManager : CLLocationManager!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
cmm = CMMotionManager()
queue = NSOperationQueue()
locationManager = CLLocationManager()
locationManager.delegate = self
compassView.layer.cornerRadius = CGRectGetWidth(compassView.frame)/2.0
}
override func viewWillAppear(animated: Bool) {
self.startUpdatingHeading()
}
override func viewWillDisappear(animated: Bool) {
self.stopUpdatingHeading()
}
/*****