如何在 iPhone 中以编程方式设置锁屏、壁纸和铃声?
在 iPhone 中,我们可以通过编程方式设置锁屏、壁纸和铃声吗?
如果是,那么请告诉我如何设置它们?
In iPhone can we set the lock screen, wallpaper and ringtone programmatically?
If Yes, then please let me know how to set them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这一切都可以轻松完成,但会被苹果拒绝。
可以通过更改
com.apple.SpringBoard.plist
(特别是ringtone
键)来更改铃声。以下代码可用于读取自定义铃声(由 iTunes 同步)的实际铃声标题。
壁纸可以在以下位置覆盖:
这些示例用于我的 Cydia 应用程序之一。其实并没有什么更多的内容,但这些应该能让你朝着正确的方向前进。
This can all be done easily, but will be rejected by Apple.
The ringtone can be changed by altering
com.apple.SpringBoard.plist
, specifically theringtone
key.The following code can be used to read the actual ringtone title of custom ringtones (synced by iTunes).
The Wallpapers can be overwritten at:
These examples were used in one of my Cydia apps. Theres not really much more to them, but these should get you going in the right direction.
由于 iOS 的更改,WrightsCS 的回答在某个时候停止工作。不幸的是,如果您想使用未记录的功能,您就必须忍受这一点。
如果您仍然需要执行此操作,仅适用于非 App Store 应用,此代码适用于 iOS 9.3。不过,它可能会在未来的任何 iOS 版本中停止工作。 (请参阅下面的评论:不再在 iOS 10 中工作)
您需要将私有 API 标头添加到您的项目中。您通常可以通过一些搜索在网上找到这些, 例如,这里。
在上面的示例中,使用参数 3 调用
[SBSUIWallpaperPreviewViewController setWallpaperForLocations:]
:3 表示图像应用于两者锁定屏幕和主屏幕。 1 表示仅锁定屏幕。 2 仅表示主屏幕。有关为什么我动态打开此框架的解释,请参阅我的相关答案。
我没有关于铃声的答案。这确实应该是一个单独的问题:完全不同的 API 在工作。
The answer by WrightsCS stopped working at some point due to a change in iOS. Unfortunately, this is something you have to live with if you wish to use undocumented features.
If you still need to do this, for non-App Store apps only, this code works in iOS 9.3. It could stop working in any future iOS release, though. (see comment below: no longer working in iOS 10)
You'll need to add the private API header to your project. You can usually find these online with a little searching, for example, here.
In the example above,
[SBSUIWallpaperPreviewViewController setWallpaperForLocations:]
is called with an argument of 3: 3 indicates the image should be used for both lock and home screens. 1 indicates Lock screen only. 2 indicates Home screen only.For an explanation of why I open this framework up dynamically, see my related answer here.
I don't have an answer regarding ringtones. This really should be a separate question: completely different APIs at work.
如果可以的话使用私有 api
检查PLStaticWallpaperImageViewController
use private api if you can
check
PLStaticWallpaperImageViewController