iPhone iPad is it possible to completely disable screen interaction and gestures programmatically?

StackOverflow https://stackoverflow.com/questions/20769433

  •  21-09-2022
  •  | 
  •  

Question

I built an ios game for my cat and he's quite fond of it. However, when he touches the screen , he repeatedly invokes all kinds of gestures - notification center, pinch to home screen, swipe between apps. I have to sit next to him and "fix" the game continuously, which defeats the purpose of an automatic game. I tried disabling gestures them in preferences, but the cat still manages to get out of the app.

Is it possible to "lock an iPhone" with screen on programmatically on vanilla iOS 7, so only the home button would exit the app?

Was it helpful?

Solution

I know you have asked how to do it programmatically. However, there is already an accessibility feature for your problem.

Go to Settings > General > Accessibility. Enable Guided Access and set a password. Once it is enabled, open your app and triple-click the home button. Your cat won't be able to leave the app even by clicking the home button.

OTHER TIPS

For ignoring interactions you can use following:

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

This tells the receiver to suspend the handling of touch-related events. Here receiver is the Application object.

and for enable interactions again use:

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

This tells the receiver to resume the handling of touch-related events.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top