Can I disable UIPickerView scroll sound?

2019-01-07 22:56发布

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

8条回答
冷血范
2楼-- · 2019-01-07 23:04

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-01-07 23:09

I found small quickie solution for this try below

        UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(0, yPickerView, VIEW_WIDTH, PICKERVIEW_HEIGHT)];
        pickerView.delegate = self;
        pickerView.dataSource = self;
        pickerView.showsSelectionIndicator = YES;
        pickerView.alpha = 0.8f;
        pickerView.tag = fieldTag;
        [pickerView selectRow:pickerViewSelectedIndex inComponent:0 animated:NO];

set the animated:NO for selectRow: method

查看更多
4楼-- · 2019-01-07 23:11

Could this trick work? Someone was able to suppress the camera shutter sound effect by playing an inverted copy of the sound at the same moment: https://stackoverflow.com/a/23758876/214070

查看更多
狗以群分
5楼-- · 2019-01-07 23:11

Maybe this not the answer for this particular question, but I had a similar problem - set minimumDate for datePicker, and I wanted set it without annoying "click" sound. After some time found very simple solution:

datePickerCustomTime.minimumDate = [[NSDate date] dateByAddingTimeInterval:300]// min time to set = now + 5 min
  [datePickerCustomTime setDate:[[NSDate date] dateByAddingTimeInterval:300] animated:NO];
查看更多
我欲成王,谁敢阻挡
6楼-- · 2019-01-07 23:18

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.

查看更多
\"骚年 ilove
7楼-- · 2019-01-07 23:21

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.

查看更多
登录 后发表回答