CLLocationManager 提示显示警报然后消失

发布于 2024-12-18 12:46:25 字数 258 浏览 2 评论 0原文

这是一个可怕的错误。使用 CLLocationManger 时,无论是通过 startUpdatingLocation 或通过 ALAsset 方法访问照片的元数据,系统都会按预期提示进行位置访问...但提示一显示就会消失。我找不到原因,希望其他人也遇到过这个问题。其他警报(例如显示 UIAlertView)不会发生这种情况。

我什至可以设置目的属性,它会显示,但同样,只显示一会儿,然后它就会自行关闭。

这对我来说是一个大问题,因为我需要获得许可才能使用照片元数据。

This is one awful bug. When using CLLocationManger, either with startUpdatingLocation or with ALAsset methods to access metadata for a photo, the system is prompting for location access as expected...but the prompt disappears as soon as it's shown. I cannot find the reason for this and am hoping someone else has had this problem. This does not occur with other alerts (such as showing a UIAlertView).

I can even set the purpose property, and it displays, but again, only for a moment then it just closes itself.

This is a big issue for me as I require permission in order to use photo metadata.

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

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

发布评论

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

评论(2

屋顶上的小猫咪 2024-12-25 12:46:25

您是否在这样的方法中创建 CLLocationManager 实例:

-(void) viewDidAppear:(BOOL)animated {
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
}

如果是这样,那么一旦函数退出,本地 locationManager 变量就会被清理。您应该在实例或静态变量中保存对 locationManager 的引用:

static CLLocationManager *locationManager;
-(void) viewDidAppear:(BOOL)animated {
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
}

Are you creating the CLLocationManager instance in a method like so:

-(void) viewDidAppear:(BOOL)animated {
    CLLocationManager *locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
}

If so, then as soon as the function exits, the local locationManager variable is being cleaned up. You should save a reference to the locationManager either on an instance or in a static variable:

static CLLocationManager *locationManager;
-(void) viewDidAppear:(BOOL)animated {
    locationManager = [[CLLocationManager alloc] init];
    locationManager.delegate = self;
    [locationManager startUpdatingLocation];
}
迷迭香的记忆 2024-12-25 12:46:25

呃,现在问题似乎已经解决了。我不知道为什么或如何。

Ugh, now the issue appears to be resolved. And I don't know why or how.

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