Device auto-lock
I have an application in which I want to lock the iPhone programmatically so that the user can't perform any action.
How can I determine the user is not working with the iPhone for some period, and after that开发者_如何学Go period automatically lock the phone?
Such applications are used in all phone devices, where the user can set an auto-lock time and then the device will automatically lock if the user does not handle the device. How is it done programmatically? Please give me one example of the code so I can perform this easily.
I am new to iPhone programming, and I am struggling in my application. Help me. Thanks in advance.
(For your lock the iphone device through programatic only )
Impossible. But , you could prevent your phone from locking when your app is running.
[UIApplication sharedApplication].idleTimerDisabled = YES
There is no way to disable the Home Button in iOS using the documented API. The user will always be able to get back to the home screen or close your application using the Home Button.
Even if you find a way do it (which is very unlikely) your app will be definitely rejected from the App Store for a blatant violation of the iOS Human Interface Guidelines. If I were you I would reconsider implementing this behaviour, frankly, it's just not a good idea.
If you're only looking for blocking the the UI of your app, check out the answers to this question, more specifically, check out the incredibly useful MBProgressHUD library:
精彩评论