0
사용자가 두 가지 방법으로 헤드폰 키를 눌렀는지 감지하려고합니다. 헤드폰 키를 감지하는 방법?
-(void)headsetMicrophoneDetection
{
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[[MPRemoteCommandCenter sharedCommandCenter].togglePlayPauseCommand addTarget:self action:@selector(onTooglePlayPause)];
NSLog(@"calling headset method");
}
-(void)onTooglePlayPause
{
NSLog(@"kishore");
}
- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent
{
NSLog(@"callig method to :)");
if (theEvent.type == UIEventTypeRemoteControl) {
switch(theEvent.subtype) {
case UIEventSubtypeRemoteControlTogglePlayPause:
NSLog(@"Hello");
break;
case UIEventSubtypeRemoteControlPlay:
NSLog(@"Hello 2");
break;
case UIEventSubtypeRemoteControlPause:
NSLog(@"Hello 3");
break;
case UIEventSubtypeRemoteControlStop:
NSLog(@"Hello 4");
break;
default:
return;
}
}
}
하지만 난이에게 NSObject의 클래스의 모든 메소드를 사용하고 난 오디오 체크 &에 대한 백그라운드 서비스를 사용할 수 뭐죠 내 코드에서 잘못된 내가 얻을 did't이 메소드를 호출 한 후
.
누락 되었습니까? MPRemoteCommandCenter에 대한 선택기를 정의 할 때 선택기에 매개 변수가 필요합니까? – ldindu
@ldindu 아니오 나는 –