RyanCW
RyanCW

Reputation: 1032

How to Add sound to UIPickerView programmatically

I can't figure out how to add a ticking sound to a UIPickerView that I have declared programmatically. In @package , struct of UIPickerView I found a member variable called "unsigned int soundsDisabled:1;" but I cannot seem to access it.

Any suggestions will be greatly appreciated.

Thanks,

Ryan Wong

Edit some COde:

-(void)initializeGame {
self.startTime = [NSDate date]; // Load the current time into startTime...

// create UIPickerView
UIPickerView *myPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, 650, 768, 216)];
myPickerView.delegate = self;
myPickerView.showsSelectionIndicator = YES;

[self.view addSubview:myPickerView];
[self resetStats];

}

Upvotes: 2

Views: 456

Answers (1)

codercat
codercat

Reputation: 23271

/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/UIKit.framework/scrollerClick.wav

Multimedia Approach:

SystemSoundID soundID;

    NSString *soundPath = [[NSBundle mainBundle] pathForResource:effectTitle ofType:@"caf"];
    NSURL *soundUrl = [NSURL fileURLWithPath:soundPath];

    AudioServicesCreateSystemSoundID ((CFURLRef)soundUrl, &soundID);
    AudioServicesPlaySystemSound(soundID);  

Upvotes: 2

Related Questions