2016-08-17 15 views
1

Apple doc은 "enabled 속성을 NO로 설정하여 해당 MPRemoteCommand 개체를 비활성화 할 수 있습니다"라고 말합니다.MPRemoteCommandCenter에서 모든 MPRemoteCommand 개체를 비활성화하는 방법

나는 Is there a public way to force MPNowPlayingInfoCenter to show podcast controls?라고 말했고 잠금 화면 제어에 대한 특정 명령을 사용 불가능하게하거나 사용 가능하게 만들 수있었습니다.

나는 라디오를 재생하고하고 작업 중 하나를 지원하지 않기 때문에 내가 잠금 화면 컨트롤에서 모든 컨트롤을 사용하지 않으려는하지만 -

나는 다음 시도 코드 "재생// 이전/일시 정지" :

MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; 
remoteCommandCenter.previousTrackCommand.enabled = NO; 
[remoteCommandCenter.previousTrackCommand removeTarget:self]; 
remoteCommandCenter.nextTrackCommand.enabled = NO; 
[remoteCommandCenter.nextTrackCommand removeTarget:self]; 

remoteCommandCenter.skipBackwardCommand.enabled = NO; 
[remoteCommandCenter.skipBackwardCommand removeTarget:self]; 
remoteCommandCenter.skipForwardCommand.enabled = NO; 
[remoteCommandCenter.skipForwardCommand removeTarget:self]; 

remoteCommandCenter.bookmarkCommand.enabled = NO; 
[remoteCommandCenter.bookmarkCommand removeTarget:self]; 

remoteCommandCenter.playCommand.enabled = NO; 
[remoteCommandCenter.playCommand removeTarget:self]; 

remoteCommandCenter.pauseCommand.enabled = NO; 
[remoteCommandCenter.pauseCommand removeTarget:self]; 

그러나 작동하지 않았습니다. 모든 것을 비활성화하면 잠금 화면에서 일시 중지, 이전, 다음 버튼을 사용할 수 있습니다. 도움을 주시면 대단히 감사하겠습니다.

답변

5

예 "enabled 속성을 NO로 설정하여 해당 MPRemoteCommand 개체를 사용하지 않도록 설정할 수 있습니다."

그러나 모든 버튼을 사용 중지하는 경우 대상을 제거하거나 타겟을 추가하지 마십시오. 아무 것도하지 않습니다. 왜 이렇게해야하는지 설명하는 문서는 없지만 이런 방식으로 작동합니다.

다음 코드를 사용해보십시오.

MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter]; 
remoteCommandCenter.previousTrackCommand.enabled = NO; 
remoteCommandCenter.nextTrackCommand.enabled = NO; 
remoteCommandCenter.skipBackwardCommand.enabled = NO; 
remoteCommandCenter.skipForwardCommand.enabled = NO; 
remoteCommandCenter.bookmarkCommand.enabled = NO; 
remoteCommandCenter.playCommand.enabled = NO; 
remoteCommandCenter.pauseCommand.enabled = NO; 


[remoteCommandCenter.previousTrackCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.nextTrackCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.skipBackwardCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.skipForwardCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.bookmarkCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.playCommand addTarget:self action:@selector(actionDoNothing:)]; 
[remoteCommandCenter.pauseCommand addTarget:self action:@selector(actionDoNothing:)]; 
+0

감사합니다. Sagar. 그 일. 목표가 어떻게 관련되어 있는지는 확실하지 않지만 나는 애플에게 같은 의견을 덧붙였다. –

+0

안녕하세요,이 시도했지만 플레이어 화면에 나타나는 일부 흰색 오버레이 및 컨트롤 센터에서 새 단추를 수 없습니다. 문제가 무엇인지 알 수 있습니까? –