views:

723

answers:

4

Hi,

I want to disable the annoying clicks that the UIPickerView generates upon scrolling up and down. Is there a way to do this? I want to play short sounds for each item that the picker view lands upon. It gets ruined by the built in sound.

I understand that the picker sounds can be turned off globally by switching off the keyboard sounds in iPhone/iPod settings. But is there a way to programatically do this?

Any help will be much appreciated!

Thanks

+1  A: 

There is an undocumented way (I'm actually not sure if it is still available in iphone 3.0) but here it is any way

#import <UIKit/UIKit.h>

@interface SilintUIPickerView: UIPickerView
{ }

- (void) setSoundsEnabled: (BOOL) enabled;
@end

use this subclass instead and call [view setSoundsEnabled: NO]

I'm interested in knowing how it goes in the latest SDK, give it a shot and let us know.

hhafez
that works perfectly! thank you so much!! By the way, do you know how particular Apple is with shunning undocumented API? This needs to hit the App store soon. Wouldn't wanna be rejected and dejected because of a thing so small :)
cocoaholic
" By the way, do you know how particular Apple is with shunning undocumented API?" I really don't know the answer to that question, try searching it on SO and if it hasn't already been asked, ask it.
hhafez
They currently warn you if you use this method.
Epsilon Prime
you always get warnings that your object may not respond to undocumented messages because they are implemented but not exposed in the header file. So that is completely expected given the fact that the solution I gave was undocumented :)
hhafez
I have had 2 application updates rejected because of this particular API call
Brent Priddy
+1  A: 

they have just rejected an app of mine because the use of undocumented api's...thats one of them.

costamatrix
+1  A: 

After using this specific undocumented api for over a year on the App Store Apple finally asked me to remove it from my App. It is very frustrating for audio apps to have that damn click sound. The best advice is to share with users that the picker sound can be disabled globally in the settings application under "Sounds" and setting "Keyboard Clicks" to "Off". I also strongly recommend visiting https://bugreport.apple.com/ and filing a bug for UIPickerView, as it can cause distortion in audio applications when the picker click is played.

ctpenrose