简体   繁体   English

iPhone-从我的应用程序iOS 6打开设置

[英]iPhone- Open Settings from my application iOS 6

I know there are many questions related to this. 我知道有很多与此相关的问题。

1) is it possible to open Settings App using openURL? 1) 是否可以使用openURL打开设置应用程序?

2) Opening the Settings app from another app 2) 从另一个应用程序打开设置应用程序

3) iOS Launching Settings -> Restrictions URL Scheme 3) iOS启动设置 - >限制URL方案

I have followed these questions for reference but that does not solve my query. 我已经按照这些问题进行了参考,但这并没有解决我的疑问。 I know that using openURL method you can open Settings but that was valid for only iOS 5.0 - 5.0.1. 我知道使用openURL方法可以打开设置,但这仅对iOS 5.0 - 5.0.1有效。 In iOS 5.1 it was deprecated. 在iOS 5.1中,它已被弃用。

  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs://"]]; 

Still I have been seeing lot of Apps mainly location based which asks for user permission to turn on Location Services and takes directly to Location Services under Settings--> Privacy. 我仍然看到许多应用程序主要基于位置,要求用户启用位置服务的权限,并直接转到设置 - >隐私下的位置服务 The screenshot of an App, which is installed on iOS 6.1 running device, below shows that tapping on Settings take you to directly Location Services . 安装在iOS 6.1运行设备上的应用程序的屏幕截图显示,点击“设置”会将您带到直接位置服务

I tried to run code in my App but it is not working (I want to take user to Settings page to allow my app to access contact information directly from my App). 我试图在我的应用程序中运行代码,但它无法正常工作(我想将用户带到“设置”页面,以允许我的应用程序直接从我的应用程序访问联系信息)。 If Apple has disabled URL Schemes for this how come many Apps are still using it? 如果Apple为此禁用了URL方案,那么许多应用程序仍在使用它?

在此输入图像描述

For apps that tie into services such as Location, the first time they request access the OS will throw out the alert with buttons that link to Settings. 对于与位置等服务相关的应用程序,当他们第一次请求访问时,操作系统将使用链接到“设置”的按钮抛出警报。 This isn't actioned by the app, but by the underlying security of the OS. 这不是由应用程序操作,而是由操作系统的底层安全性操作。

iOS 6 removed the ability to do this yourself as you mentioned. 如上所述,iOS 6自行删除了自行执行此操作的功能。

You can open settings app programmatically in iOS8, but not in earlier versions of iOS. 您可以在iOS8中以编程方式打开设置应用程序,但不能在早期版本的iOS中打开。

In Swift: 在Swift中:

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

Swift 4: 斯威夫特4:

if let url = NSURL(string: UIApplicationOpenSettingsURLString) as URL? {
    UIApplication.shared.openURL(url)
}

In Objective-C 在Objective-C中

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM