当我在应用程序 didFinishLaunchingWithOptions 中收到 UIApplicationLaunchOptionsLocationKey 时,是否初始化 viewController?
我正在创建一个应用程序,它侦听重要的位置更改事件,如果应用程序终止,iOS 将启动设置了 UIApplicationLaunchOptionsLocationKey 的应用程序。
因此,文档说要创建一个新的位置管理器并再次注册位置更新。但是,没有提到我是否应该初始化我的 viewController (就像我在正常的应用程序启动中所做的那样)?我的视图控制器在 viewDidLoad 中初始化,但在 appDidFinishLaunchingWithOptions 中创建。
知道操作系统为应用程序提供了多少时间来处理位置更新吗?如果位置更改表明应用程序感兴趣的位置,我的应用程序需要发出 Web 服务请求。
谢谢
I'm creating an app which listens to significant location change events and in case the app gets terminated then the iOS launches the app with UIApplicationLaunchOptionsLocationKey set.
So, the documentation says to create a new location manager and register for location updates again. However, doesn't mention if I'm supposed to initialize my viewController (as I do in normal app launch as well)? My view controllers initialize in viewDidLoad but are created in appDidFinishLaunchingWithOptions.
Any idea how much time does OS provides to the App for location update handling? My app needs to make a webservice request if the location change indicates an interested location for the app.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该考虑将初始化代码移至新方法,例如
initializeViews
。此方法将检查以确保视图尚未初始化,然后初始化它们。您可以从application:didFinishLaunchingWithOptions:
和applicationWillEnterForeground:
调用此方法,但application:didFinishLaunchingWithOptions:
中的调用仅在应用程序未启动时才会发生不会进入后台。You should consider moving your initialization code to a new method, something like
initializeViews
. This method would check to make sure the views haven't been initialized and then initialize them. You would call this method fromapplication:didFinishLaunchingWithOptions:
andapplicationWillEnterForeground:
, but the call inapplication:didFinishLaunchingWithOptions:
would only occur if the application wasn't going to the background.