摇一摇

自带shake API

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 检测到摇动 */
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 摇动取消(被中断) */
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event /** 摇动结束 */

摇一摇时开启震动

引入头文件

#import <AudioToolbox/AudioToolbox.h>

加入这句代码即可

AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);

posted @ 2015-12-15 15:11  Mr_tao  阅读(158)  评论(0编辑  收藏  举报