[英]iOS - Application delegate - Calling didBecomeActive with CLLocationManager
I've a typical problem. 我有一个典型的问题。 In my application, I'm handling the application delegate method
在我的应用程序中,我正在处理应用程序委托方法
- (void)applicationDidBecomeActive:(UIApplication *)application
to refresh the UI. 刷新UI。
As my application won't be terminated and running in background, when ever the app comes to active state, this method is being called and working fine. 由于我的应用程序不会终止并在后台运行,因此只要该应用程序进入活动状态,就可以调用此方法并正常工作。
But in one of my view controller, i'm creating CLLocationManager object 但是在我的一个视图控制器中,我正在创建CLLocationManager对象
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self; // send loc updates to myself
The problem is that, when this location manager object is being created, application delegate's "applicationDidBecomeActive" is also being called which is not necessary for me to handle. 问题是,当创建此位置管理器对象时,还调用了应用程序委托的“ applicationDidBecomeActive”,这对我来说不是必需的。 How should I neglect the call when location manager object is being initialized?
初始化位置管理器对象时,如何忽略呼叫?
发生这样的调用很奇怪,但是如果没有办法阻止它,只需在默认值中加上一个标记,如callAfterSettingDelegate ,然后在DidBcomeActive
检查是否在此之后调用了该标记,请忽略此调用并将该标记设置为零。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.