1、打开摇一摇功能
[UIApplication sharedApplication].applicationSupportsShakeToEdit =YES;
2、让需要摇动的控制器成为第一响应者
[selfbecomeFirstResponder];
3、实现以下方法
// 开始摇动
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent*)event
// 取消摇动
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
// 摇动结束
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event