iOS iPhone 添加 摇一摇后 让手机震动或者铃声设置

来源:互联网 发布:ec20模块linux驱动 编辑:程序博客网 时间:2024/04/29 18:15

工程添加摇一摇方法 


#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);

}



0 0