在iOS锁屏界面中自定义应用程序的远程事件处理

7
Spotify如何处理自定义远程事件?目前在运行iOS 8.1.3和Spotify版本2.4.0.1822的iPhone 6上,当我打开Spotify电台时,锁屏界面会显示以下控件。我尝试阅读所有有关远程事件的文档,但无法找到任何允许从锁屏界面发送自定义远程事件的资源。
1个回答

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。您可能会看到一个定制的锁屏。

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


1
@kalpa模拟器现在不支持控制中心。 因此,您无法在模拟器上看到此功能。 - beryu

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接