| Summary: | Dim or hide the Home indicator on iPhone X (and future iOS devices without a Home button) | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Dominik Reichardt <sdl-bugzilla> |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | 2.0.7 | ||
| Hardware: | iPhone/iPod touch | ||
| OS: | iOS 11 | ||
| Attachments: | proposed partial patch for SDL_uikitappdelegate | ||
It *should* be enough to add this in SDL_uikitviewcontroller.m but it seems there is something odd going on with the SDL_uikitmessagebox.m code. When you show an alert either of these methods to handle the Home indicator do no longer work.
A good testcase is testsprite.c:
- in the void loop, while (SDL_PollEvent(&event)) { add switch and a case SDL_FINGERDOWN to show a simple SDL Messagebox:
/* Check for events */
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_FINGERDOWN:
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Simple MessageBox", "Just a simple messagebox", NULL);
break;
}
}
- add -(BOOL)prefersHomeIndicatorAutoHidden in SDL_uikitviewcontroller.m
- when you run the testsprite2 test via TestiPhoneOS.xcodeproj the Home indicator will be hidden after second. When you touch the screen the SDL Messagebox will show, cancel it and the Home indicator will no longer hide.
Good info, thanks! This is implemented with a hint controlling the behavior, along with a fix for the message box, here: https://hg.libsdl.org/SDL/rev/fe303e78ea49 Created attachment 3158 [details]
proposed partial patch for SDL_uikitappdelegate
For my project I needed the check in both locations and added the changes in the patch to @implementation SDLLaunchScreenController.
Without it the home indicator hint only "took" after the first UIAlertController alert. Very likely something wrong in my project, though :(
I will need to compare how other projects handle this properly.
I tested this with testsprite2.c Do you have something else going on in your app launch sequence? I think we can close it, I'm pretty sure it is something odd that Exult is doing. Coming from SDL 1.2x and then being ported to SDL2 and iOS might have led to strange things. And since our development team is no longer very active and I'm not really good... bla bla bla :) Let's leave it as resolved :) Thanks a lot! |
The Home indicator is thick line at the bottom of the screen that you swipe up to get to the Home screen. it can be pretty distracting but Apple, for now, doesn't want to give an option to hide it. In your own code you can have two options to deal with it in the viewcontroller: You can hide it but it will reactivate on every touch event - so it's only good for programs that don't require interactivity often (e.g. video playback) via -(BOOL)prefersHomeIndicatorAutoHidden { return YES; } You can dim it (translucent) and it will only react to a second swipe via - (UIRectEdge)preferredScreenEdgesDeferringSystemGestures { return UIRectEdgeBottom; } It's either/or, you cannot mix them, when you auto hide the indicator you cannot dim it via the second code. In SDL2 2.0.7 code, I was able to implement this by adding these to SDL_uikitappdelegate.m under the @implementation SDLLaunchScreenController and in SDL_uikitviewcontroller.m under @implementation SDL_uikitviewcontroller. I needed to add ti to both or an UIAlertController (for example an SDL messagebox) would at least unset the UIRectEdge way. Implementing it like this is probably wrong and more likely needs to go into AppDelegate but I couldn't make that work, so no patch for it. Also to control the behavior it should have yet another SDL Hint (0= default, 1= autohide, 2= dim).