2014-01-24 38 views
8

我的應用程序不支持返回上一首曲目,而且我想知道是否可以告訴鎖屏音樂控件隱藏倒帶/上一首曲目按鈕。我使用MPNowPlayingInfoCenter將該信息傳遞給鎖定屏幕。我可以在iOS鎖屏音樂控件中隱藏倒帶按鈕嗎?

很簡單的問題,可以這樣做嗎?例如,只顯示播放/暫停,並跳過?

回答

17

從iOS 7.1開始,有一種方法可以自定義鎖屏和指令中心(以及其他許多附件)中可用的控件:MPRemoteCommandCenter

關於你的問題,你可以做到以下幾點:

[MPRemoteCommandCenter sharedCommandCenter].previousTrackCommand.enabled = NO; 
[MPRemoteCommandCenter sharedCommandCenter].skipBackwardCommand.enabled = NO; 
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = NO; 

// You must also register for any other command in order to take control 
// of the command center, or else disabling other commands does not work. 
// For example: 
[MPRemoteCommandCenter sharedCommandCenter].playCommand.enabled = YES; 
[[MPRemoteCommandCenter sharedCommandCenter].playCommand addTarget:self action:@selector(play)]; 

Please see this Stack Overflow answer for more general information about MPRemoteCommandCenter

+1

「你還必須註冊任何其他命令才能控制命令中心,否則禁用其他命令不起作用。」感謝您提供這個有價值的信息! – tom

+0

我看到它隱藏了前面的按鈕以及 – onmyway133

+0

嗨我試過這個,但播放器屏幕和控制中心出現一些白色覆蓋,我不能夠新的按鈕。你有什麼想法會是什麼問題? –

9

發佈時間:

我認爲簡短的答案是否定的。該文件說明了這一點 -

「您無法直接控制顯示哪些信息或其格式。根據要提供給系統的信息設置正在播放的信息中心詞典的值。系統或連接的附件,以一致的方式處理所有應用程序的信息顯示。「

+0

有趣。謝謝:) – Luke

相關問題