How to play tock sound when tapping custom keyboard buttons

后端 未结 6 756
闹比i
闹比i 2020-12-29 16:09

I\'ve been working on a custom keyboard for iOS 8 for some time and everything went fine so far, but I still couldn\'t get my head around this tapping sound stuff.

I

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-29 16:55

    Finally I got an answer from other SO thread.

    - (void)playSound
    {
        NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"Tock" ofType:@"caf"];
        SystemSoundID soundID;
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath: soundPath], &soundID);
        AudioServicesPlaySystemSound (soundID);
    }
    

    I have implemented and verified this method works on both simulators and devices on iOS8 Beta 2.

提交回复
热议问题