Aao*_*oIi -2
首先,您应该将以下方法添加到您的UIViewController子类中:
override func canBecomeFirstResponder() -> Bool {
return true
}
Run Code Online (Sandbox Code Playgroud)
接下来是添加motionEnded:withEvent:方法:
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent?) {
if motion == .MotionShake {
print("Shaked")
}
}
Run Code Online (Sandbox Code Playgroud)
祝你好运 :)
| 归档时间: |
|
| 查看次数: |
2702 次 |
| 最近记录: |