views:

561

answers:

1

My iPhone application has code that handles the event for when the iPhone falls asleep, and re-awakens. My question is, how do I test this using either the iPhone or the simulator. Is there a hotkey or command to force the phone or simulator to fake "go to sleep?".

Thanks.

+3  A: 

Yes, Command-L ("Lock" on the "Hardware" menu) will lock the simulator.

It will not go to sleep, but according to the documentation, this should be enough to trigger the "applicationWillResignActive" method:

"The delegate can implement this method to make adjustments when the application transitions from an active state to an inactive state. When an application is inactive, it is executing but is not dispatching incoming events. This occurs when an overlay window pops up or when the device is locked."

Kobski
Perfect, thanks!
Kevin