【问题标题】:How to add seek buttons on iOS lock screen?如何在 iOS 锁屏上添加搜索按钮?
【发布时间】:2017-05-26 15:48:45
【问题描述】:

如何设置 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;

【问题讨论】:

    标签: ios objective-c mpnowplayinginfocenter


    【解决方案1】:

    您还需要按照https://stackoverflow.com/a/24818340/1514970 中的说明设置preferredIntervals

    【讨论】:

    • 太棒了! @waywalker,非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    • 2014-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多