简体   繁体   English

iOS-应用程序委托-使用CLLocationManager调用didBecomeActive

[英]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.

相关问题 CLLocationManager没有在NSObject中调用委托 - CLLocationManager not calling delegate in an NSObject CLLocationManager不调用其委托方法 - CLLocationManager not calling its delegate method 在ios中实现了doUpdateLocations委托CLLocationManager的方法 - implement didUpdateLocations delegate method of CLLocationManager in ios 在调用application:didBecomeActive(iOS)时,rootViewController是否总是准备好提出提示? - Is rootViewController always ready to present a segue by the time application:didBecomeActive is called (iOS)? CLLocationManager委托未称为ios 11(Swift) - CLLocationManager delegate not called ios 11 (swift) 在iOS 8中未调用CLLocationmanager updateLocations委托方法 - CLLocationmanager updateLocations delegate method not getting called in iOS 8 将ViewController连接到委托类-CLLocationManager / iOS8 - Connecting a viewcontroller to a delegate class - CLLocationManager / iOS8 CLLocationManager未在iOS 10.2中调用didUpdateLocation()[Swift] - CLLocationManager not calling didUpdateLocation() in iOS 10.2 [Swift] 如果后台任务到期,则不调用didBecomeActive - Not calling didBecomeActive if background task expires 如何对iOS应用程序代表方法的调用进行单元测试? - How Can I Unit Test Calling of iOS Application Delegate Methods?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM