单独的 CLLocationManager 用于位置和位置标题?
我在几本书中注意到,经常创建两个 CLLocationManager 实例,一个用于位置,另一个用于标题。如果您想要为每个方法分配一个单独的委托,我可以理解这一点,但所有方法都是唯一的,因此我无法真正想到这样做的原因。我是否遗漏了什么,或者是否可以简化这一点并使用一个 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 have noticed in a few books that quite often two instances of CLLocationManager are created, one for location and a separate one for heading. 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?
// 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];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从来没有这样做过,而且我的所有应用程序都运行得非常好 - 我只是对两个应用程序使用相同的应用程序:)
我什至无法开始思考如果代表相同,您为什么会这样做!
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!