2016-04-28 20 views
0

我确信之前已经问过这个问题,但我似乎无法找到它,而且我也不确定如何改写它。如何在IOS中响应低功耗提示?

在IOS 9+功率不足时,iOS会提示您选择低功耗模式。

我希望能够在此应用程序可见时暂停应用程序中的活动。

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

谢谢!

回答

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这是每当显示任何系统弹出调用。

3

关注NSProcessInfoPowerStateDidChangeNotification,如React to Low Power Mode on iPhones中所述。如果您收到通知,检查状态:

一旦程序被通知功率状态改变的,它应该然后查询isLowPowerModeEnabled来确定当前的电源状态...

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