How do I hide the Home Indicator?

Hello,

I’m developing a game and would like to home indicator to hide when the screen isn’t touched. In xcode, I’d use prefersHomeIndicatorAutoHidden in Swift or Obj-C, but that option’s not available in XOJO.

Would anyone be able to help guide me in implementing this in a XOJO iOS project?

John

This is similar to the macOS sample I did the other day. prefersHomeIndicatorAutoHidden is a read-only instance property which means that in most cases it needs to be implemented on the iOS view controller itself (the thing that the view instance is created from).

https://www.dropbox.com/scl/fi/qoct2t1oedihzo4vy3zwk/home_indicator_ios.xojo_binary_project?rlkey=ibl5s1nwd7rioexnvk1s5wzy9&dl=1

This demo project shows how to do what you want, but just so you understand what’s going on here, this method needs to be called before the screen is shown, because the property needs to be added to the parent class before the property would be requested.

In the sample project, I’ve created a screen called StartScreen which is completely blank. Its Opening event serves one purpose, instantiate screen1, create the property and then show the screen. Unfortunately I can’t find a way to intercept it fast enough to affect the first screen.

NOTE: I’ve used an array of WeakRefs to keep track of the views where you’ve chosen to set this property to True. This is to prevent MobileScreens from leaking memory.

1 Like

For clarity, Apple’s docs also say:

The system takes your preference into account, but returning YES is no guarantee that the indicator will be hidden.

1 Like

Thank you! Yes, that’s the solution I was looking for. :slight_smile:

I’ve sent a pull request to Jérémie to make it part of iOSDesignExtensions.

2 Likes