Status bar hiding when landscape-only view controller is presented over portrait-only view controller
Asked Answered
P

2

6

I have a navigation controller holding a view controller that only supports the portrait orientation:

enter image description here

This presents a full-screen view controller that only supports landscape:

enter image description here

Unfortunately during the transition, the status bar on the presenting view controller is removed, which makes the content jerk up before the transition begins. I've implemented a custom fade transition to make the effect obvious:

enter image description here

Note that the status bar is not present. This is done before the custom transition starts, with no animation, so even if I take a snapshot before the transition begins and add it to the container view, you still see the reduced navigation bar momentarily.

Is there a non-terrible way to fix this? I don't want to have to add the snapshot outside of the transition (like this answer).

I have tried making the presentation style custom instead of full-screen, but this doesn't leave the device in the portrait orientation. A solution using a custom presentation style which leaves the device in the landscape orientation would also be acceptable.

There is a sample project demonstrating the problem here

Porphyrin answered 5/8, 2015 at 11:32 Comment(2)
Hey! Did you figure out a valuable solution for this? Thanks.Cuthbert
Same Problem over here. Any good solutions so far?Selfgovernment
R
0

May be too horrible a hack but if it is the view jerking that bothers rather than the status bar disappearance itself could you change the constraints so that the top isn't constrained to the top layout guide but to the superview top with an appropriate constant?

Ravelment answered 5/8, 2015 at 11:52 Comment(3)
Wouldn't that still leave the navigation bar changing size?Porphyrin
Probably but I thought it might not be as disturbing. I'm not that happy with answer, might remove it.Ravelment
You did inspire me though, so thanks. I think I might have a solution but it is a little bit horriblePorphyrin
G
0

I might be missing something but does hiding the bar just before the transition look any better ?

self.navigationController?navigationBarHidden = true in prepareForSegue and turn it back on in viewWillAppear

Grove answered 7/8, 2015 at 7:5 Comment(1)
I want the presenting view controller to stay looking the same.Porphyrin

© 2022 - 2024 — McMap. All rights reserved.