我已将iPhone的Tock声音添加到我自己的自定义键盘中,如下所示:
NSString *path = [[NSBundle bundleWithIdentifier:@"com.apple.UIKit"] pathForResource:@"Tock" ofType:@"aiff"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID);
AudioServicesPlaySystemSound(soundID);
// we don't dispose of the sound to keep the sound in the cache for the next time
//AudioServicesDisposeSystemSoundID(soundID);
Run Code Online (Sandbox Code Playgroud)
然而,在iPhone OS 3.1中,键盘Tock声音已被低沉,例如比其他声音更安静,而不是3.0.我的方法的声音仍然很响,并且音量最大.我怎样才能获得与iPhone默认键盘相同的音量?
顺便说一句,Twitterrific中的Tock声音适当地低沉.
干杯
MrMage
我创建了一个用作自定义一个UICollectionViewController的子类inputAccessoryViewController中UITextView.
https://developer.apple.com/reference/uikit/uiresponder/1621124-inputaccessoryviewcontroller
当您使用playInputClick点击集合视图中的单元格时,我想播放键盘单击声音. https://developer.apple.com/reference/uikit/uidevice/1620050-playinputclick
我无法弄清楚如何在集合视图中使用它.它适用于这样的简单视图使用a的inputAccessoryView属性,UITextView但我不确定在集合视图控制器层次结构中的子类视图,以获得键盘单击声音.
@interface KeyboardClickView : UIView <UIInputViewAudioFeedback>
@end
@implementation KeyboardClickView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if(self)
{
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)];
[self addGestureRecognizer:tap];
}
return self;
}
- (void)tap:(id)sender
{
[[UIDevice currentDevice] playInputClick];
}
- (BOOL)enableInputClicksWhenVisible
{
return YES;
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_inputAccessoryView = [[KeyboardClickView alloc] initWithFrame:CGRectMake(0, 0, 0, 50)];
_inputAccessoryView.backgroundColor = [UIColor redColor];
[[UITextView appearance] setInputAccessoryView:_inputAccessoryView]; …Run Code Online (Sandbox Code Playgroud) 我的iPhone应用程序中有一个按钮,我想在点击时播放默认的"键盘敲击"声音.我已经能够轻松地播放我自己的自定义声音,但有没有办法在我的应用程序中播放这样的默认系统声音?