Search code examples
iphoneobjective-cxcodeiphone-3gs

Lock-screen iPhone


My question is quite simple (I think and hope). I would like to know what happens when I lock my phone. I made a little clock-like app which should play and loop a sound at a given moment (lets say 18:00). But when I press the power button, and the phone locks, nothing happens at 18:00. When I press the power button again 18:05 and the "lock screen" shows, then the sound is played.

Please note, I didn't return to the home screen before locking the phone. The app is still open, when I unlock the app is shown. Is there some way to let the app still do its thing eventhough I locked the screen? Or is this just a programming error I might have made?

Regards, Paul Peelen


Solution

  • You should take a look at information about the application delegate’s applicationWillResignActive: and applicationDidBecomeActive: methods. You can find this information in the iPhone Application Programming Guide. Also, take a look at information about "The Automatic Sleep Timer" in the same guide.

    http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/ApplicationEnvironment.html#//apple_ref/doc/uid/TP40007072-CH7-SW59

    I think you can answer most of your own questions with this information but please post any follow up questions that you might have.

    Bart