Swift

import UIKit

 
class ViewControllerUIViewController {
 
    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("摇晃被意外终止")
    }
}
原文地址:https://www.cnblogs.com/-ios/p/8384031.html