工程添加摇一摇方法
#pragma mark yaoyiyao
- (BOOL)canBecomeFirstResponder
{
return YES;// default is NO
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
//处理摇一摇之后响应的事件
//添加震动功能
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
SystemSoundID soundId;
NSString *path = [[NSBundle mainBundle]pathForResource:@“song” ofType:@"avr"];
AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundId);
AudioServicesPlaySystemSound(soundId);
}
本文介绍如何在iOS应用中实现摇一摇功能,并通过播放震动及声音效果增强用户体验。文章详细展示了如何利用AudioServicesPlaySystemSound进行震动反馈,以及如何加载并播放自定义的声音文件。
4959

被折叠的 条评论
为什么被折叠?



