浏览应用程序时运行定位服务
所以我的 iPhone 项目中有两个视图控制器 - 其中一个收集用户位置数据并连续保存到文件中,另一个则执行其他操作(并不重要)。一旦用户翻转到另一个视图控制器,我希望保持位置更新运行,因为我正在记录他的位置并将其保存到文件中。如何在其他视图控制器上继续运行位置更新和文件保存(即使我总共有超过 2 个视图控制器)?
谢谢!
So I have two view controllers in my iphone project - one of them collects user location data and saves to a file continuously, and the other one does something else (doesnt really matter). I would like to keep the location updates running once the user flips to the other view controller since I am logging and saving to a file his location. How can I keep running the location updates and file savings while on other view controllers (even if I had more than 2 view controllers total)?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建 CLLocationManager 的实例并开始监视位置更改(或重大位置更改,如果适合您的话)。您可以在 AppDelegate 或与视图控制器无关的其他类中创建此实例。
Create an instance of CLLocationManager and start monitoring for location changes (or significant location changes if that works for you). You can create this instance in your AppDelegate or some other class that is unrelated to the view controllers.