简体   繁体   English

单独的CLLocationManager用于位置和方向吗?

[英]Separate CLLocationManager for location & heading?

I have noticed in a few books that quite often two instances of CLLocationManager are created, one for location and a separate one for heading. 我在几本书中注意到,通常会创建两个CLLocationManager实例,一个实例用于定位,另一个实例用于标题。 If you wanted a separate delegate for each I could see the point, but all the methods are unique so I can't really think of a reason for doing this. 如果您希望每个人都有一个单独的代表,我会明白这一点,但是所有方法都是唯一的,因此我真的没有想到这样做的原因。 Is there something I am missing, or is it possible to simplify this and use one CCLocationManager for both location and heading? 我缺少什么吗?或者可以简化此过程,并使用一个CCLocationManager进行位置和方向?

// LOCATION
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[customMapView setShowsUserLocation:YES];

// HEADING:
headingManager = [[CLLocationManager alloc] init];
[headingManager setDelegate: self];
[headingManager setHeadingFilter:kCLHeadingFilterNone];
[headingManager startUpdatingHeading];

I've never done this and all my apps have worked absolutely fine - I'd just use the same one for both :) 我从来没有做过,而且我所有的应用程序都运行得非常好-我会为两个应用程序都使用相同的一个:)

I can't even begin to think of a reason why you would do this if the delegates were the same! 我什至无法想到如果代表相同的情况下您会这样做的原因!

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

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