1、打開搖一搖功能
[UIApplication sharedApplication].applicationSupportsShakeToEdit =YES;
2、讓需要搖動(dòng)的控制器成為第一響應(yīng)者
[selfbecomeFirstResponder];
3、實(shí)現(xiàn)以下方法
// 開始搖動(dòng)
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent*)event
// 取消搖動(dòng)
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
// 搖動(dòng)結(jié)束
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event