0

I am in process of migrating my Swift2.3 project to Swift3.1. As a part of it, I am facing trouble with a swipe controller that I used - 'ezswipeviewcontroller'.

I am using Xcode8.3, and testing on iOS10.3.2 device/simulator.

Before conversion, the ViewController (with navigatioBar) was properly displayed under the status bar but after conversion the ViewController (with navigatioBar) goes beneath the status bar.

I looked at the SO solutions and understood that the below will work, which DID NOT work in my case :-|

edgesForExtendedLayout = []    
extendedLayoutIncludesOpaqueBars = false    
automaticallyAdjustsScrollViewInsets = false

Here below are the screenshots for reference -

Before Conversion Screenshot After Conversion Screenshot

Lohith Korupolu
  • 1,066
  • 1
  • 18
  • 52

2 Answers2

0

Give your view a layout top constraint to its superview (either in storyboard or with code), let it be relative to margins. It will now start under the status bar. You might have to add leading, trailing and bottom constraints too, to avoid upsetting autolayout.

kevin
  • 442
  • 3
  • 13
  • Will give that try right now. But isn't it something that the OS should take care of? And why did it change after the swift conversion? Any clue? – Lohith Korupolu Jul 25 '17 at 12:16
  • @LohithKorupolu The OS doesn't know what you want to do, you tell it you want to draw the view under status bar by setting a constraint with a margin. That's how it's been for as long as I can remember, I think you changed more than just the swift version, because the language has no effect on this, only the SDK and perhaps the OS version. – kevin Jul 25 '17 at 12:29
  • Your suggestion gives me a different result. The navigation bar in the ViewController stays at the same place. And the rest moves down. – Lohith Korupolu Jul 25 '17 at 12:39
  • @LohithKorupolu Sounds like you set the constraint for the view of the childviewcontroller. If you want the navigation bar to move, do this for the navigation controller's view. – kevin Jul 25 '17 at 13:16
  • this navigation bar is created programatically, not on storyboard. I am using 'ezswipecontroller'. Could you help me how I can add a top constraint programatically? – Lohith Korupolu Jul 25 '17 at 13:19
0

I resolved this issue by setting the height of the navigationBar of EZSwipeViewController from 44 to 64.

public static let navigationBarHeight: CGFloat = 64

And everything is perfect now! :-)

Lohith Korupolu
  • 1,066
  • 1
  • 18
  • 52
  • Is this solution still working for you? I tried setting this constant as well, but it seems to be completely ignored for some reason. In addition, it doesn't take the case of notch status bars into account. Curious to know if you are still using this component and how you make it work on modern iPhones. – Sebastien Apr 14 '19 at 03:27