Swift - 手机摇晃的监测和响应
import UIKit
class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } //开始摇晃 override func motionBegan(motion: UIEventSubtype, withEvent event: UIEvent) { println("开始摇晃") } //摇晃结束 override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) { println("摇晃结束") } //摇晃被意外终止 override func motionCancelled(motion: UIEventSubtype, withEvent event: UIEvent) { println("摇晃被意外终止") }}posted on 2018-01-30 10:56 yucaijiang 阅读(242) 评论(0) 收藏 举报
浙公网安备 33010602011771号