简体   繁体   English

iOS:启动应用程序时不显示位置服务授权警报视图

[英]iOS: location services authorization alert view is not displayed when app is started

I asked this question a couple days ago about my app not showing up under Settings > Location Services after reinstall. 我几天前问了这个问题,关于我的应用在重新安装后没有显示在“设置”>“位置服务”下。 I found out that after reinstalling, I have to run the app and wait for the "Use Current Location" authorization alert view to be displayed for the app to show up under the Location Services list. 我发现,重新安装后,我必须运行该应用程序并等待显示“使用当前位置”授权警报视图,以使该应用程序显示在“位置服务”列表下。 In turn, I found out that my app doesn't display this alert view instantly when the app is started. 反过来,我发现我的应用在启动时不会立即显示此警报视图。

Here's some bits of code that might be the problem: 这是可能是问题的一些代码:

-(void)restartGps: (UIWebvView *)curWebView {
  [locationManager startMonitoringSignificantLocationChanges];
  [self performSelector:@selector(noGpsLock:) withObject:curWebView afterDelay:GPS_TIMEOUT];
}

-(void)noGpsLock: (UIWebView *)curWebView {
  if (!hasLocationFix) {
    [locationManager stopMonitoringSignificantLocationChanges];
    [self performSelector:@selector(restartGps:) withObject:curWebView afterDelay:GPS_TIMEOUT];
  }
}

hasLocationFix is set to be TRUE when -locationManager:didUpdateToLocation:fromLocation: is called. -locationManager:didUpdateToLocation:fromLocation:时, -locationManager:didUpdateToLocation:fromLocation:设置为TRUE。

I initially call restartGps: in viewDidLoad and let the two methods call each other from then on. 我最初在viewDidLoad调用restartGps:然后让这两个方法相互调用。 I found out that the first time restartGps: is called (from viewDidLoad ), the alert didn't appear, therefore the app couldn't get any location. 我发现第一次(从viewDidLoad )调用restartGps: ,没有出现警报,因此应用程序无法获得任何位置。 After a noGpsLock: and a restartGps calls, the alert finally appeared and the app was able to get a location. 经过noGpsLock:restartGps调用后,警报最终出现,并且该应用程序能够获取位置。

Why is the alert not showing up the first time restartGps: is called? 为什么在首次启动restartGps:时未显示警报?

Maybe this link can help 也许此链接可以帮助您

Adding a Requirement for Direction-Related Events 添加与方向相关的事件的要求

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

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