Lnpopupcontroller: Safe area issue

Created on 28 Oct 2017  ·  14Comments  ·  Source: LeoNatan/LNPopupController

Hey Leo,

I've hit into an issue and hope it's something you'll be able to fix. I present my popup content as a UINavigationController, which can push new VCs to the stack. The problem is the top safe area value is not correct. I've updated the example project to demonstrate the issue, I modified the Swift example with the map.

I've updated the Storyboard to "Use Safe Area Layout Guides" and created a new TestVC which I instantiate in code. I'm simply showing a green view of 10 pixel in height at the top of the safe area.

Example 1
Screenshot:
https://www.dropbox.com/s/upv8jh4vwz0lavv/Simulator%20Screen%20Shot%20-%20iPhone%208%20-%202017-10-28%20at%2016.41.10.png?dl=0

Code:
https://github.com/jyounus/LNPopupController/commit/242c62c7815d0f86e01dfdb55aa56a55bcdb922a#diff-5e7d938b4cf5e317345d02934192b496R35

Expected outcome:
The green view should be aligned just underneath the status bar. This works as expected.

Example 2
Screenshot:
https://www.dropbox.com/s/6c3m1yxi6dpw346/Simulator%20Screen%20Shot%20-%20iPhone%208%20-%202017-10-28%20at%2016.41.28.png?dl=0

Code:
https://github.com/jyounus/LNPopupController/commit/242c62c7815d0f86e01dfdb55aa56a55bcdb922a#diff-5e7d938b4cf5e317345d02934192b496R39

Expected outcome:
The green view should be aligned just underneath the nav bar. This isn't working as expected, you don't see the green view at all (it's behind the translucent nav bar, however since I'm using the top safe area, it should be working correctly).

Example 3
Screenshot:
https://www.dropbox.com/s/gycepbes1eksarh/Simulator%20Screen%20Shot%20-%20iPhone%208%20-%202017-10-28%20at%2016.41.50.png?dl=0

Code:
https://github.com/jyounus/LNPopupController/commit/242c62c7815d0f86e01dfdb55aa56a55bcdb922a#diff-5e7d938b4cf5e317345d02934192b496R43

Expected outcome:
The green view should be aligned just underneath the nav bar. This isn't working as expected, there is a small gap between the nav bar and the green view.

I have been testing this using Xcode 9, iOS 11 and the simulators (8 in this case).

Do you have any idea why the top safe area guide isn't working correctly? Not sure if this is related to https://github.com/LeoNatan/LNPopupController/issues/184 since this bug expects the nav bar to be translucent.

bug

All 14 comments

Hmmp… Yep, doesn’t look good. I don’t think it’s related to 183. Keep that branch alive—I will take a look soon.

BTW, if you run on iOS 10, does it work as expected?

Just downloaded the iOS 10 simulators and tested it on iPhone 5 10.3.1. Exactly the same behaviour as the iOS 11 iPhone 8 simulator for all 3 examples.

Out of curiosity, I changed the deployment target of the example project to iOS 9 (not pushed to my branch) and tested it with the iPhone 5 9.3 simulator. Exact same behaviour for all 3 examples as well.

OK, thanks. I will look when I have time.

Fixed!

I've just tried it and it works fine on the "normal" iPhone simulators, however on the iPhone X there's still an issue. The issue is only with test case 2, here's a screenshot:
https://www.dropbox.com/s/l2e1jnqupkyodx4/Simulator%20Screen%20Shot%20-%20iPhone%20X%20-%202017-12-08%20at%2010.27.44.png?dl=0

I've updated my branch to use your latest code and also updated the example project to have scenario 2 active by default.

I believe it's to do with line 324 in your fix. That works fine for older phones, but is incorrect for the iPhone X since we'll always need some sort of distance from the top to not overlap with the status bar.

Ohhh. Fucking X 😂
Thanks, will fix soon.

Yes, it probably needs to be the window's top inset instead of 0.

I think I’ve finally fixed it. Please check and let me know.

The issue with the top safe area is fixed now. :)

However I noticed another issue, this time with the bottom safe area. I updated my branch again to show the problem.

Here's a screenshot: https://www.dropbox.com/s/jitz2nk9v5p530k/Simulator%20Screen%20Shot%20-%20iPhone%20X%20-%202017-12-17%20at%2011.12.20.png?dl=0

The bottom blue view on the iPhone X shouldn't be touching the bottom. In my code code, this can be reproduced with scenario 2 and 3. This works perfectly fine for scenario 1 (just uncomment the relevant code to see it in action).

😓😭

I have pushed yet another fix. Please test and find more bugs ❤️

Nope, it broke non-X devices.

Tested it on the iPhone X and iPhone 5S simulators on iOS 11, in both landscape and portrait mode for all 3 examples. All working fine now. Also works fine in my actual project now, thank you for the work and the awesome lib! :D

Yay!

Was this page helpful?
0 / 5 - 0 ratings