在 iPod Touch 上的应用程序内部以编程方式启用位置服务

发布于 12-04 04:43 字数 372 浏览 2 评论 0原文

我有一个使用 GPS 进行定位服务的 iOS 应用程序。用户希望在带有外部 GPS 的 iPod Touch 上使用该应用程序,但问题是用户无法在该应用程序的“设置”->“常规设置”->“位置服务”中启用“位置服务”。

当应用程序在 iPhone 上运行时,在“设置”->“常规设置”->“位置服务”中,该应用程序会显示一个切换开关,用于启用/禁用该应用程序的位置服务。但是,当该应用程序在 iPod Touch 上运行时,该应用程序不会显示在“设置”->“常规设置”->“位置服务”中。

有谁知道我需要以编程方式执行什么操作,才能使该应用程序的位置服务在 iPod Touch 上运行时在“设置”->“常规设置”->“位置服务”中通过切换开关显示?

I have an iOS application that uses GPS for Location Services. A user would like to use the app on an iPod Touch with an external GPS, but the problem is that the user can't enable Location Services in Settings->General Settings->Location Services for this app.

When the app is run on an iPhone, in Settings->General Settings->Location Services, the app shows up with a toggle switch to enable/disable Location Services for this app. But when the app is run on an iPod Touch, the app doesn't show up in Settings->General Settings->Location Services.

Does anyone know what I need to do programmatically to cause Location Services for this app to show up with a toggle switch in Settings->General Settings->Location Services when run on an iPod Touch?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

花想c2024-12-11 04:43:27

我认为这种能力是在第一次实现 CLLocationManager 时出现的。我不确定这是否与外部 GPS 接收器一起使用,但如果您从 GPS 获取纬度/经度,则可以将这些坐标发送到位置管理器。

I think that the ability comes when CLLocationManager is implemented for the first time. I'm not sure if that is what's used with an external GPS receiver but if you're getting the Lat/Long from the GPS, you can send those coordinates to the location manager.

∞觅青森が2024-12-11 04:43:27

我明白问题出在哪里了。我有以下代码,仅允许 iPhone 定位服务,而不允许 iPod。哎呀!

if([model hasPrefix:@"iPhone"]){

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.distanceFilter = 10.0f;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [self.locationManager startUpdatingLocation];
    self.locations = [NSMutableArray arrayWithCapacity:32];

}

I figured out what the problem was. I had the following code that only allowed Location Services for iPhone and not for iPod. Oops!

if([model hasPrefix:@"iPhone"]){

    self.locationManager = [[CLLocationManager alloc] init];
    self.locationManager.delegate = self;
    self.locationManager.distanceFilter = 10.0f;
    self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    [self.locationManager startUpdatingLocation];
    self.locations = [NSMutableArray arrayWithCapacity:32];

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