How to get dial pad beep sound on iOS 7


How to get dial pad beep sound on iOS 7.

I have a dialpad in my app and would like to use iOS 7 dial pad sound.The one like the figure enter image description here

I tried some other methods but was not proper and sound won't get reduced at time of muting the device.

Thank You.


Answers:


First of all import .wav audio files 0 to 9 in audio box and name them properly like i wrote code here for files like DTMF_00.wav to DTMF_09.wav so you have to named this file as your wish but keep in mind that you have to change NSString *toneFilename = [NSString stringWithFormat:@"DTMF_%02d", count]; this line and give your file names.

and then you have to #import <AudioToolbox/AudioToolbox.h> both in viewController.h

in .h file declare SystemSoundID toneSSIDs[10]; in { } of interface like this

@interface yourViewController : UIViewController{ SystemSoundID toneSSIDs[10]; }

set an button action event in header file and set it to all button.(keep in mind don't create action events for individual you have to create only one click event)

then you have to write this code on .m file above or below - (void)viewDidLoad

-(id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if(self)
    {

        for(int count = 0; count < 10; count++){
            NSString *toneFilename = [NSString stringWithFormat:@"DTMF_%02d", count];

            NSURL *toneURLRef = [[NSBundle mainBundle] URLForResource:toneFilename withExtension:@"wav"];

            SystemSoundID toneSSID = 0;

            AudioServicesCreateSystemSoundID((__bridge CFURLRef) toneURLRef,&toneSSID);
            toneSSIDs[count] = toneSSID;
        }
    }

    return self;
}

then

-(IBAction)numberButtonPressed:(UIButton *)pressedButton
{
    int toneIndex = [pressedButton.titleLabel.text intValue];
    SystemSoundID toneSSID = toneSSIDs[toneIndex];
    AudioServicesPlaySystemSound(toneSSID);
}