我的应用程序不支持返回到上一首轨道,我想知道是否可以让锁屏音乐控件隐藏其倒带/上一首轨道按钮。我使用 MPNowPlayingInfoCenter
将该信息传达给锁定屏幕。
很简单的问题,能做到吗?例如,只显示播放/暂停和快进?
最佳答案
从 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 .
关于ios - 我可以隐藏 iOS 锁屏音乐控件中的快退按钮吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21334128/