I have an app which requires the use of location services, but attempts to fetch data every minute. This means that even if the user allows location services after a second, it'll be another 59 before it refreshes. Is it possible to know when app permissions changed?
问问题
189 次
1 回答
1
好的好的,我会做一个答案大声笑。
不过,不要相信我的话,我鼓励您先尝试一下,看看它是否能满足您的需求。
-(void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
// -----------------------------------------
// Available authorization status are:
//
// kCLAuthorizationStatusAuthorized
// kCLAuthorizationStatusDenied
// kCLAuthorizationStatusNotDetermined
// kCLAuthorizationStatusRestricted
// -----------------------------------------
if(status == kCLAuthorizationStatus...)
{
// do something here
}
}
它是一个 CLLocationManager 委托,因此您需要创建一个 CLLocationManager 对象,然后将其委托设置为 self 并使您的视图控制器符合 CLLocationManagerDelegate 协议:
// .h file
@interface MyClass <...,CLLocationManagerDelegate,UITableViewDelegate,....>
{
CLLocationManager *locationManager;
}
// in the .m file
-(void)viewDidLoad
{
...
locationManager.delegate = self
}
于 2013-05-21T13:00:07.877 回答