2012-02-09 61 views
1

我想访问用户当前Location.When我调用CLLocationManager(startUpdating)。CLLocation Manager(如何启用“使用当前位置”)

其显示的是alertview ex。 “Xyz App想要使用您当前的位置”。 如果用户点击“不允许”。现在如果我检查授权状态,它回复2“表示拒绝”。 我检查状态,如果它的2(手段拒绝),我会让showalertview“某某想用你的当前位置”

现在,如果用户点击“允许”如何以编程方式启用它,而不是用户去设置屏幕&手动启用。

回答

4

您不能以编程方式启用用户点击不允许的方式。您只需通知用户,他必须转到设置 - >定位服务,并为您的应用启用它,如果他想使用此功能。

您可以设置该位置的purpose,它将显示在操作系统显示的第一个警报视图中,当将要求用户许可时。

purpose 

An application-provided string that describes the reason for using location services. 
@property(copy, nonatomic) NSString *purpose 
Discussion 

If this property is not nil and the system needs to ask for the user’s consent to use location services, it displays the provided string. You can use this string to explain why your application is using location services. 

You must set the value of this property prior to starting any location services. Because the string is ultimately displayed to the user, you should always load it from a localized strings file. 
+0

如果用户点击了不允许。下次如果用户再次去app.Its不显示alertview。 – Rupesh 2012-02-09 07:30:15

+0

没有那只是当应用程序尝试访问位置服务时第一次。每次您必须检查CLAuthorizationStatus并根据它提醒用户 – 2012-02-09 07:40:52

+0

他们是没有其他方法没有以编程方式启用服务? – Rupesh 2012-02-09 07:42:45