mardi 17 février 2015

This very simple code for a sound button builds but doesn't work on iPhone


#import "ViewController.h"

@implementation ViewController

-(IBAction) playSound1; {
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef soundFileURLRef;
soundFileURLRef = CFBundleCopyResourceURL(mainBundle, (CFStringRef)@"Knave", CFSTR ("caf"), NULL);
UInt32 soundID;
AudioServicesCreateSystemSoundID(soundFileURLRef, &soundID);
AudioServicesPlaySystemSound(soundID);
}


This is my m file code for the IBAction. As I say, it builds, and the button press 'visually' works... but the audio file doesn't play. It's exactly the same as the tutorial I followed, and his worked fine... So what on earth am I doing wrong?


Aucun commentaire:

Enregistrer un commentaire