Objective c 可编程设置Info.plist是或否
嗨,StackOverflow开发者,我有一个问题,我如何设置我的Info.plist可编程是或否。所以我的应用程序支持Background Locaton更新。但正如所有iOS开发者所知,它会像坚果一样杀死电池。因此,我想检测iphone是否已插入,然后只支持后台进程,如果未插入,我们可以使用[LocationManager startMonitoringSignificantLocationChanges];。谢谢你的帮助 对原问题的答复 OP询问如何停止更新位置,答案是 CLLocationManager有一个stopUpdateLocation:方法 新问题的答案 据我所知,属性列表用于声明您打算在后台使用位置服务,并且在运行时的可访问性方面是只读的。因此,似乎正确的方法是通过StopUpdateLocation:和startMonitoringSignificantLocationChanges:等方法控制CLLocationManager 通过使用注册电池通知,您可以根据电池状态通过电池监控来控制CLLocationManagerObjective c 可编程设置Info.plist是或否,objective-c,ios,xcode,plist,Objective C,Ios,Xcode,Plist,嗨,StackOverflow开发者,我有一个问题,我如何设置我的Info.plist可编程是或否。所以我的应用程序支持Background Locaton更新。但正如所有iOS开发者所知,它会像坚果一样杀死电池。因此,我想检测iphone是否已插入,然后只支持后台进程,如果未插入,我们可以使用[LocationManager startMonitoringSignificantLocationChanges];。谢谢你的帮助 对原问题的答复 OP询问如何停止更新位置,答案是 CLLocatio
[ [ UIDevice currentDevice ] setBatteryMonitoringEnabled:YES ];
[ [ NSNotificationCenter defaultCenter ] addObserver:self selector:@selector(
reactToBatteryStatus) name:UIDeviceBatteryLevelDidChangeNotification object:nil ];
通过此功能,您可以确定手机是否已插入。然而,根据苹果公司的指导方针,您应该只在需要时注册电池通知。所以要注销您使用的
[ [ UIDevice currentDevice ] setBatteryMonitoringEnabled:NO ];
[ [ NSNotificationCenter defaultCenter ] removeObserver:self name:
UIDeviceBatteryLevelDidChangeNotification object:nil ];
然后根据电池状态,你可以做你需要的事情
+ (void) reactToBatteryStatus {
UIDeviceBatteryState batteryState = [ UIDevice currentDevice ].batteryState;
if ( batteryState == UIDeviceBatteryStateCharging || batteryState == UIDeviceBatteryStateFull )
{
// Device is plugged in.
}
}
禁用地图是什么意思?您想停止获取位置更新吗?@sosborn我已更改了我的问题:请不要在回答问题后更改您的问题,现在您收到的答案不匹配,并且不再是资源。如果系统阻止您提出新问题,请不要完全改变你的老问题,以绕过这一点。这被认为是对内容的诽谤。我是soory Brad Larson和Abizen我不得不问这个问题:我已经改变了我的问题。你明白我的问题了吗?我是soory,因为我被禁止提问,所以我不得不编辑这个问题。节日快乐:感谢您检测到电池更换,但我们如何将背景位置的Info.plist更改为是或否:是否可以将Info.plist更改为是/否。我想您可以从这里找到答案。我将停止添加评论,因为我得到警告,要避免在评论中进行长时间的讨论。