如何以编程方式将声音添加到UIPickerView

时间:2013-11-22 11:24:46

标签: objective-c uipickerview

我无法弄清楚如何向我以编程方式声明的UIPickerView添加滴答声。在@package中,UIPickerView的结构我找到了一个名为“unsigned int soundsDisabled:1;”的成员变量。但我似乎无法访问它。

任何建议都将不胜感激。

谢谢,

Ryan Wong

编辑一些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];

}

1 个答案:

答案 0 :(得分:2)

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

多媒体方法:

SystemSoundID soundID;

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

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