UIEventSubtypeRemoteControlTogglePlayPause没有做任何事
问题描述:
我有一个播放音乐并希望使用锁屏控制(播放/暂停)的应用程序。 使用NSLog我可以看到我的应用程序获得按钮触发器,但不是UIEventSubtypeRemoteControlTogglePlayPause。UIEventSubtypeRemoteControlTogglePlayPause没有做任何事
这里有点我的代码:
- (void)viewDidLoad {
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
- (BOOL)canBecomeFirstResponder {
return YES;
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent
{
NSLog(@"REMOTE RECEIVE");
if (receivedEvent.type == UIEventTypeRemoteControl)
{
NSLog(@"received remote event");
switch (receivedEvent.subtype)
{
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"toggle button received");
//[self togglePlayPauseTapped: nil];
break;
default:
break;
}
}
我从NSLog的输出,但没有行内的“端的接收”和“接受远程事件” ...... TogglePlayPause。
任何想法?
答
的情况下使用
UIEventSubtypeRemoteControlPause
UIEventSubtypeRemoteControlPlay
为iOS 7
答
接受的答案是不清楚。
UIEventSubtypeRemoteControlPlay
,UIEventSubtypeRemoteControlPause
和UIEventSubtypeRemoteControlStop
被称为用户交互内。
UIEventSubtypeRemoteControlTogglePlayPause
被称为耳机互动。