ios - 从另一个应用程序打开设置应用程序

好的,我知道有很多关于它的问题,但它们都是很久以前的。

所以。我知道这是可能的,因为 Map 应用程序可以做到。

在 map 应用程序中,如果我关闭此应用程序的本地化,它会向我发送一条消息,如果我按下确定,“设置应用程序”将打开。 我的问题是,这怎么可能? 如何从我自己的应用程序中打开“设置应用程序”?

基本上我需要做同样的事情,如果用户关闭我的应用程序的位置,那么我会向他显示一条消息,说明将打开“设置应用程序”

最佳答案

如 Karan Dua 所述这是now possible in iOS8使用 UIApplicationOpenSettingsURLString 见 Apple's Documentation .

示例:

swift 4.2

UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)

在 Swift 3 中:

UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)

在 Swift 2 中:

UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)

在 Objective-C 中

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

iOS 8 之前的版本:

你不能。正如您所说,这已被多次介绍,并且要求您打开位置服务的弹出窗口由 Apple 提供,而不是由应用程序本身提供。这就是它能够打开设置应用程序的原因。

这里有一些相关的问题和文章:

is it possible to open Settings App using openURL?

Programmatically opening the settings app (iPhone)

How can I open the Settings app when the user presses a button?

iPhone: Opening Application Preferences Panel From App

Open UIPickerView by clicking on an entry in the app's preferences - How to?

Open the Settings app?

iOS: You’re Doing Settings Wrong

https://stackoverflow.com/questions/5655674/

相关文章:

ios - 错误 : _handleNonLaunchSpecificActions in iOS9

ios - 更改 UIImageView 的图像时淡入淡出/溶解

ios - 带有隐藏 UIView 的自动布局?

ios - 如何在 UITableViewCell 之间添加间距

ios - 在 iOS 6 中以编程方式打开 map 应用

ios - 获取 UIScrollView 滚动到顶部

objective-c - 如何判断 UITableView 何时完成 ReloadData?

objective-c - 从 NSString 中删除除数字之外的所有数字

objective-c - 仅在 iOS 7 上运行时,Storyboard 原型(prototyp

ios - UIButton 标题文本颜色