how to lock Iphone by programmatically [duplicate]

2019-03-02 07:48发布

问题:

This question already has an answer here:

  • Programmatically lock and unlock iPhone screen 8 answers

Is there is any option to lock the Iphone by Software Code. Currently I am working in Flex 4 . I couldn't get any idea about this work. actually my Iphone covered by thick panel , it's very difficult to press the lock button . so I planned to create a shortcut for lock Iphone by coding. Kindly give me some Idea about this task, using Flex 4 or other Languages also is okay. thanks in advance.

回答1:

If you want to do this so, Apple never approve this, your app must be jailbreak. you can do this by calling Private framework on your project. you can use GraphicsServices.framework. note , this GraphicsServices.framework is a private framework. Apple never accept your app. By calling GSEventLockDevice() method you can lock your Iphone Device easily. This GSEventLockDevice() resides in the GSEvent.h. hope this one helps .



回答2:

You can not do this using flex or the iOS SDK. You can, however, enable AssistiveTouch by going into Settings -> General -> Accessibility -> AssistiveTouch which will put a little button on your screen that when tapped will allow you to lock your device



回答3:

You can't do this on a device that isn't jailbroken- Apple won't let you. Even if you did figure out a way to somehow do this, it would never pass the submission process. If you are developing for jailbroken devices, it's another story, but for the App Store, what you want is impossible.