如何在 iOS 锁定屏幕上添加搜索按钮?
How to add seek buttons on iOS lock screen?
如何设置MPRemoteCommandCenter/MPNowPlayingInfoCenter添加搜索按钮?我想要实现的结果在屏幕截图上。
我已经添加了这段代码:
[[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
[weakSelf rewindForward];
return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
[weakSelf rewindBackward];
return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = YES;
您还需要按照 中的说明设置 preferredIntervals
。
如何设置MPRemoteCommandCenter/MPNowPlayingInfoCenter添加搜索按钮?我想要实现的结果在屏幕截图上。
[[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
[weakSelf rewindForward];
return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekForwardCommand.enabled = YES;
[[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
[weakSelf rewindBackward];
return MPRemoteCommandHandlerStatusSuccess;
}];
[MPRemoteCommandCenter sharedCommandCenter].seekBackwardCommand.enabled = YES;
您还需要按照 中的说明设置 preferredIntervals
。