Open realModusOperandi opened 5 years ago
UIKit will change scroll views’ content insets depending on whether the top and bottom bars (navbar and toolbar in this case) are transparent. Usually what you want to do (without loss of generality) is always have the view confroller’s view go to the bottom, then let the content inset be applied as appropriate. If something isn’t working as expected, check the layout method/constraints, then start twiddling with the many UIViewController properties that mention insets and their adjustment.
Also what works on iOS 12 may not work on iOS 10 may not work on iOS 9 so consider firing up those simulators too.
Welcome to the world of safe areas!
I don't think this has anything to do with safe areas. It's not a case of a view being there but having no content--the PostsPageViewController's root view just simply does not expand to fill the available space. The topmost view in the hierarchy in that grey part is a UIViewControllerWrapper that seems to belong to the UINavigationController.
What I've noticed is that it has something to do with the translation of the autoresizing mask on the PPVC's view into constraints. Everything appears to be fine until after viewWillAppear, at which point constraints are applied and somehow the UIView-Encapsulated-Layout-Height constraint is set to a wrong value:
whereas before the view actually appears, things seem to line up much better:
Translucent toolbar (normal):
begin viewDidLoad: (0.0, 0.0, 414.0, 896.0)
end viewDidLoad: (0.0, 0.0, 414.0, 896.0)
begin viewWillAppear: (0.0, 0.0, 414.0, 808.0)
end viewWillAppear: (0.0, 0.0, 414.0, 808.0)
begin viewDidAppear: (0.0, 0.0, 414.0, 808.0)
end viewDidAppear: (0.0, 0.0, 414.0, 808.0)
Opaque toolbar (bugged):
begin viewDidLoad: (0.0, 0.0, 414.0, 896.0)
end viewDidLoad: (0.0, 0.0, 414.0, 896.0)
begin viewWillAppear: (0.0, 0.0, 414.0, 808.0)
end viewWillAppear: (0.0, 0.0, 414.0, 808.0)
begin viewDidAppear: (0.0, 0.0, 414.0, 642.0)
end viewDidAppear: (0.0, 0.0, 414.0, 642.0)
At this point I would need some sort of debug trace for the laying out of the subviews of the navigation controller when the PPVC is pushed to see where the correct value is turning into the incorrect value. None of the constraints on the toolbar appear to be showing the problem and there are no other constraints I can see in the hierarchy.
Huh. Maybe we need to set some constraints instead of just setting a frame and autoresizing mask? Anyway, sounds like you’re on it, lmk if I can help (beyond randomly guessing at things, which is always available at no charge).
Update: I needed to set extendedLayoutIncludesOpaqueBars = true
on PostsPageViewController
to get rid of the empty space, and edgesForExtendedLayout = .bottom
to ensure the top bar can still appear. Sound reasonable?
Not sure about the opaque bars part. Extending just the bottom makes sense as we do show content behind the (semitransparent iirc) toolbar.
To be honest, I often need fifteen minutes and a whiteboard to figure out what combination of extended layout settings I need and whether I’m seeing what I expect. I have no intuition for it whatsoever.
The opaque bars part is necessary to get rid of the weird gap when I set the Toolbar to be opaque, which I need to do if we're going to get it to be true black like other apps (I'm looking at Tweetbot most heavily) did for their OLED theme. There are no changes necessary for the current themes. I won't just blindly apply these settings to all themes, I'll figure out how to only apply them when needed.
Oh I see. You probably explained that to me before and I forgot.
We could add a key to the relevant themes' plists for making the bottom toolbar opaque. Have it default to transparent so existing themes work as-is. Happy to help if that’s not enough to go on.
When I use the Parent Forum button I get a grey bar just above the bottom nav. — spanky the dolphin
Loving the SUPER BLACK, but I am getting some weird gray bar thing at the bottom of the screen while in threads.
It appears to be due to the bottom bookmark trying to slide off the screen when entering a thread and the block of space getting “stuck” and floating at the bottom. I can make a video if needed. XS if that’s any help. Seems to be limited to the OLED mode. — Warbird
I think I’ve fixed this on master branch?
This seems to be getting worse, and the app is quitting in background much quicker than it used to. — Jealous Cow
In starting work on #834 I have run into an issue that someone may be able to help with. When I set isTranslucent to false so that the toolbar can be truly black, the UIView that PostsPageViewController owns decides it's going to be smaller than the available space between the navbar and the toolbar, leaving a glitchy empty space:
Anyone know what could be going on here?