核心位置最佳放置和用户中断 [英] Core Location Best Placement and User Interruption

查看:132
本文介绍了核心位置最佳放置和用户中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在三个不同的视图中使用Core Location。它的工作完美在我的第一个视图中,我将CLLocationManager子类化,并使用协议方法来调用类的位置更新。在我的其他类安装框架和代码之前,我想知道:

My application uses Core Location in three different views. It's working perfectly. In my first view, I subclass the CLLocationManager and use protocol methods for location updates to my calling class. Before I install the framework and code in my other classes, I was wondering:

协议方法是最好的方法吗?

Is the protocol method the best way?

如果用户在尝试获取位置修复时退出视图或退出应用程序,Core Location执行会发生什么情况?是否立即关闭了GPS系统的位置任务?

What happens to the Core Location execution if the user exits the view or quits the app while it's trying to get a location fix? Is the location task terminated with the GPS system turned off immediately?

如果用户只需切换到另一个视图,可以假设我可以在下一个视图不考虑最后一个?

If the user simply switches to another view, is it OK to assume that I can start Core Location in the next view without regard to the last?

应该在哪里放置第一个更新位置。应用程序委托应使用协议来实例化CLLocation Manager类,以便它可以更新所选择的任何视图或每个类都应该实例化管理器。

Where should the first update location call be placed. Should the application delegate instantiate the CLLocation Manager class using protocol so that it can update any of the views chosen or should each class instantiate the manager.

任何反馈将不胜感激。

Any feedback would be appreciated.

谢谢。

推荐答案

既然你真的不>需要多个 CLLocationManager ,您可以尝试将其创建为应用程序委托的属性。然后,当您加载视图时,在视图控制器的 -viewWillAppear:animated:方法中,包含一个 [locationManager setDelegate:self]; 行,它将开始向当前可见的视图控制器发送委托消息。

Since you don't really need more than one CLLocationManager, you could try creating it as an property of your application’s delegate. Then, when you load your views, in the -viewWillAppear:animated: method of your view controller, include a [locationManager setDelegate:self]; line and it will start sending delegate messages to the currently-visible view controller.

这篇关于核心位置最佳放置和用户中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆