views:

298

answers:

4

Hello,

I'm new to iPhone SDK.

Any idea how to put the iPhone into the sleep mode from within the code (my application), as if the user has clicked the sleep/wake button?

Best regards.

+2  A: 

Your UIApplicationDelegate will have

- (void)applicationWillResignActive:(UIApplication *)application

called when the lock button is pressed but there does not seem to be a way to trigger this from code.

I'm pretty sure this will be disallowed.

You are not permitted to make changes to the state of the device (change volume etc) which would not be expected by the user.

Kevin
+1  A: 

There is no offical way to make the iPhone or iPod go into sleep mode or to lock the screen.

St3fan
+1  A: 

You have to remember that the iPhone is not a little laptop. It is also a phone and therefor an emergency communications device. Developers are not allowed to do anything that might interfere with the users control of the phone.

TechZen
A: 

iphone sleep for save energy ?

ezygamelink