【问题标题】:Custom remote event handling in app from iOS lock screen来自 iOS 锁屏的应用程序中的自定义远程事件处理
【发布时间】:2015-02-23 15:56:16
【问题描述】:

Spotify 如何处理自定义远程事件?目前在运行 iOS 8.1.3 和 spotify 版本 2.4.0.1822 的 iPhone 6 上,当我打开 Spotify 收音机时,我在锁定屏幕上获得以下控件。我已经尝试阅读与远程事件有关的所有文档,但我找不到任何允许来自锁定屏幕的自定义远程事件的资源。

【问题讨论】:

    标签: ios objective-c cocoa-touch uikit uiresponder


    【解决方案1】:

    也许这是用 MPRemoteCommandCenter 实现的。 这是示例...

    MPRemoteCommandCenter *remoteCommandCenter = [MPRemoteCommandCenter sharedCommandCenter];
    [[remoteCommandCenter skipForwardCommand] addTarget:self action:@selector(skipForward)];
    [[remoteCommandCenter togglePlayPauseCommand] addTarget:self action:@selector(togglePlayPause)];
    [[remoteCommandCenter pauseCommand] addTarget:self action:@selector(pause)];
    [[remoteCommandCenter likeCommand] addTarget:self action:@selector(like)];
    

    实现此代码,在您的应用上播放音乐并锁定您的 iPhone。您可能会看到自定义的锁定屏幕。

    注意 - 菜单可以自定义标签,但不能自定义图标图像和行数。

    【讨论】:

    • @kalpa Simulator 现在不支持控制中心。所以,你在模拟器上是看不到这个功能的。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-20
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多