当应用程序第一次尝试获取用户位置时,系统会提示他们“想使用您当前的位置”,他们可以点击不允许或确定。有什么方法可以确定用户是否点击了确定或不允许?我试图让 MKMapView 向用户显示当前位置,但我想根据用户的选择采取不同的行动。
通常你会认为会有一个代表来获取这些信息,但似乎没有。
在此先感谢您的帮助。
当应用程序第一次尝试获取用户位置时,系统会提示他们“想使用您当前的位置”,他们可以点击不允许或确定。有什么方法可以确定用户是否点击了确定或不允许?我试图让 MKMapView 向用户显示当前位置,但我想根据用户的选择采取不同的行动。
通常你会认为会有一个代表来获取这些信息,但似乎没有。
在此先感谢您的帮助。
Your first call to get the user's location will fail with an error which tells you the user has denied location services. Your CLLocationManagerDelegate
method didFailWithError
will be called, as below. (The constants are defined in CLError.h
)
- (void)locationManager:(CLLocationManager*)aManager didFailWithError:(NSError*)anError
{
switch([anError code])
{
case kCLErrorLocationUnknown: // location is currently unknown, but CL will keep trying
break;
case kCLErrorDenied: // CL access has been denied (eg, user declined location use)
message = @"Sorry, flook has to know your location in order to work. You'll be able to see some cards but not find them nearby";
break;
case kCLErrorNetwork: // general, network-related error
message = @"Flook can't find you - please check your network connection or that you are not in airplane mode";
}
}