单独的 CLLocationManager 用于位置和位置标题?

发布于 2024-10-05 00:25:27 字数 653 浏览 0 评论 0原文

我在几本书中注意到,经常创建两个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无人问我粥可暖 2024-10-12 00:25:27

我从来没有这样做过,而且我的所有应用程序都运行得非常好 - 我只是对两个应用程序使用相同的应用程序:)

我什至无法开始思考如果代表相同,您为什么会这样做!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文