0
点赞
收藏
分享

微信扫一扫

Swift - 手机摇晃的监测和响应

转角一扇门 2022-07-18 阅读 61

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("摇晃被意外终止")
}
}

举报

相关推荐

0 条评论