如何在iOS锁屏上添加搜索按钮?

时间:2017-05-26 15:48:45

标签: ios objective-c mpnowplayinginfocenter

如何设置MPRemoteCommandCenter / MPNowPlayingInfoCenter以添加搜索按钮?我想要实现的结果是截图。 Seek buttons should look like 我已经添加了这段代码:

[[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;

1 个答案:

答案 0 :(得分:1)

您还需要按照https://stackoverflow.com/a/24818340/1514970

中的说明设置preferredIntervals