What to do when pushing a view that's smaller than the underlying one?

266 views Asked by At

I have an iPhone app that's presenting a typical master/detail view, starting with a tableview. When a row is tapped, I push the view controller for that row (which is loaded from a storyboard). The views for each row are all of various sizes, some containing only a few controls.

I find that iOS doesn't push the underlying view away smoothly; if the incoming view is smaller than the current one, a fragment of the current one moves awkwardly only partly to the left and remains visible before blinking out.

Watch the bottom here.

That bottom bar is not a toolbar, by the way. It's laid out on the main view explicitly, like anything else.

Here's how the incoming view is invoked (tabBoard is a storyboard):

    if let singlePageController = tabBoard.instantiateViewController(withIdentifier: tabName) as? AtomViewController
    {
        navigationController?.pushViewController(singlePageController, animated: true)
    }

I could make an unnecessarily large incoming view, but this is a hokey workaround considering that I don't know the resolution of the user's device or of future devices. And there's no way I can see of making the topmost view auto-resize to the safe area. I've set autoresizing to expand the view, but no dice.

I've also tried setting the incoming view controller's view frame to equal the current safe area. The frame size is changed (to one that indeed looks full-screen), but the transition is still messy.

What gives?

enter image description here

2

There are 2 answers

0
Oscar On

In the end, the solution was to make sure the incoming view's background color wasn't set to "clear." Setting all the views' backgrounds to black eliminated the problem.

This would have been more obvious if iOS had simply left the underlying view in place, so we could see it through the "clear" overlying view. The fact that the underlying view moves up and partially off the screen to the left... and then stalls and just blinks out... doesn't seem intended.

1
G-Mathi On

Please check these boxes in the ViewController setting.

  1. Hide bottom bar on push
  2. Use Full Screen

enter image description here