微信摇一摇功能大家想必用过~ ios SDK帮我们完成了所有功作,我们只需要添加相应的逻辑即可
下面贴出实现代码(在对应的ViewController中添加如下代码):
#pragma mark - motion refresh
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"开始摇动");
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//振动效果
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"结束摇动");
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event {
NSLog(@"取消");
}AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/xiaokfc/article/details/46848385