【发布时间】:2014-05-07 09:40:19
【问题描述】:
我想检测连接到 ipad 的蓝牙键盘何时按下播放/暂停音乐按钮。键盘是“ACTECK FT-850”。
我正在使用这种方法来检测其他按钮。
-(NSArray * ) keyCommands
{
if ([[[UIDevice currentDevice] systemVersion] intValue] !=7) return nil;
UIKeyCommand *Letter = [UIKeyCommand keyCommandWithInput: @"a" modifierFlags: 0 action: @selector(Letter:)];
UIKeyCommand *upArrow = [UIKeyCommand keyCommandWithInput: UIKeyInputUpArrow modifierFlags: 0 action: @selector(upArrow:)];
return [[NSArray alloc] initWithObjects: upArrow, Letter,nil];
}
- (void) Letter: (UIKeyCommand *) keyCommand
{
NSLog(@"LETRA A");
}
- (void) upArrow: (UIKeyCommand *) keyCommand
{
NSLog("Do something");
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
效果很好,但我不知道在KeyCommandWithInput 中输入了什么字母 o 命令来检测“播放/暂停”音乐按钮,...我也已经尝试过了:
-(void)viewDidAppear:(BOOL)animated
{
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
{
NSLog(@"ENTER TO REMOTE CONTROL");
if (theEvent.type == UIEventTypeRemoteControl) {
switch(theEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"SE TOCO EL BOTON PLAY/PAUSE");
case UIEventSubtypeRemoteControlPlay:
NSLog(@"SE TOCO EL BOTON PLAY");
break;
default:
return;
}
}
}
但是当我按下按钮时,永远不会调用remoteControlReceivedWithEvent。
请帮帮我。
【问题讨论】:
标签: ios bluetooth media-player bluetooth-lowenergy ios-bluetooth