【问题标题】:CLLocationManager prompt is displaying alert then disappearingCLLocationManager 提示显示警报然后消失
【发布时间】:2012-01-09 01:54:55
【问题描述】:

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

我什至可以设置 purpose 属性,它会显示出来,但同样,只是片刻之后它就会自行关闭。

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

【问题讨论】:

标签: iphone ios5 cllocationmanager cllocation alassetslibrary


【解决方案1】:

您是在这样的方法中创建 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];
}

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 我也有这个问题,如果有人能帮忙的话:)
    • @AndreiStoleru 我添加了一个可能对你有帮助的答案
    猜你喜欢
    • 2018-08-13
    • 2015-02-02
    • 1970-01-01
    • 2015-10-08
    • 1970-01-01
    • 2011-06-02
    • 1970-01-01
    • 2016-05-03
    • 1970-01-01
    相关资源
    最近更新 更多