Apple Watch: Status bar not visible after presenting a modal screen from page based navigation

后端 未结 1 1275
闹比i
闹比i 2020-12-16 02:10

When i present a modal screen from a page in page based navigation, the whole screen shifts up and the status bar is no longer visible.
Here is a gif of the issue:

相关标签:
1条回答
  • 2020-12-16 02:50

    This is a known issue in the final release that exhibits itself in two cases:

    1. When presenting a second modal controller (paging or single) over an existing paging modal controller
    2. When presenting a menu using Force Touch over a paging modal controller

    This has been discussed in the Apple Developer Forums, and the only workaround I've heard about is one that I use in my app. Unfortunately, there's no simple code to share that solves the problem, so I'll describe the approach (which I'd consider messy, but workable).

    First, you need to keep track of interface controller presentations. I have a framework for this, but you may have to roll your own. When a child interface controller has its willActivate called two times in a row (in other words, without a call to a different child interface controller) you can assume that a modal was presented/dismissed on top of it.

    Your presenting/parent controller can then inform all children that the modal menu bug has happened, and those child controllers can unhide a replacement status bar with its own Cancel/Close button. With some work, you can recreate a pixel-perfect version of the standard status bar with identical behavior.

    The final twist is to detect when your Watch app is suspended, then resumes. In that case, willActivate is also called twice. If you don't handle that situation, you'll end up unhiding the replacement status bar and have two on the screen simultaneously. Not a great scenario.

    Getting this right is very tricky, but it does work. I just wish I had a simple code sample that you could inject.

    Update: I pushed some of my workaround code to GitHub: https://github.com/mikeswanson/JBInterfaceController

    0 讨论(0)
提交回复
热议问题