如何应对IOS中的低功耗提示?

时间:2016-04-28 17:30:11

标签: ios performance battery

我确信之前已经问过,但我似乎无法找到它,我不知道如何改写它。

在IOS 9+中,当功率变低时,iOS会提示您选择使用低功耗模式。

当此警报可见时,我希望能够在我的应用中暂停活动。

我确信我可以使用委托方法。有谁知道它的名字?

谢谢!

2 个答案:

答案 0 :(得分:3)

按照React to Low Power Mode on iPhones中的说明关注NSProcessInfoPowerStateDidChangeNotification。收到通知后,请检查状态:

  

一旦您的应用程序收到电源状态更改通知,它应该查询isLowPowerModeEnabled以确定当前的电源状态......

     

您的应用可以随时通过访问查询当前的电源状态   NSProcessInfo类的isLowPowerModeEnabled属性,如   如清单7-2所示。该属性包含一个布尔值,   指示是启用还是禁用低功耗模式。

答案 1 :(得分:1)

或许你只是在寻找

- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
主appDelegate.m中的

只要显示任何系统弹出窗口,就会调用此方法。