我有一个关于 iphone 开发的问题。我正在为使用 gps 的 iphone 构建一个应用程序,我可以通过提醒用户是否要使用 gps 来处理我的应用程序中的 gps。如您所知,它何时会尝试使用 gps,iphone 的内置 gps 也会询问是否允许它使用。所以这是我的问题,我怎么知道用户点击了 iphone 的内置弹出窗口
因为我在失败时显示“Gps 不工作”警报。那么当只有 gps 不工作而不是当用户单击“他不想使用 gps”时,我怎样才能让警报弹出
实施
- (void)locationManager: (CLLocationManager *)manager
didFailWithError: (NSError *)error
委托方法...如果error code
是=kCLErrorNetwork
那么它是gps错误,如果error code = kCLErrorDenied
然后用户拒绝...你可以像
switch([error code])
{
case kCLErrorNetwork: // general, network-related error
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"please check your network connection or that you are not in airplane mode" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
case kCLErrorDenied:{
//User has denied
return;
}...