从iOS锁定屏幕在应用程序中自定义远程事件处理

时间:2015-02-23 15:56:16

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

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

enter image description here enter image description here

1 个答案:

答案 0 :(得分:6)

也许这是通过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。您可能会看到自定义锁定屏幕。

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