skip to Main Content

I am having trouble pinning the UIButton to the bottom of my UIViewController, (There is a tab bar if that helps).
Here are the constraints of the UIButton.

enter image description here

Originally, it all worked fine, but ever since I added iPad support to the application I have issues. on the iPad the UIButton is pinned to the bottom of the screen, directly above the tab bar. However on iPhone, there is this empty gap at the bottom.
enter image description here

What I Tried
Doing some research I saw that sometimes split view controller causes a grey bar, I added this line of code to resolve it and it fixed the bottom bar , but this constraint issues is still causing me a headache.

self.extendedLayoutIncludesOpaqueBars = true

iPad View Hierarchy

enter image description here

iPhone View Hierarchy

4

Answers


  1. Remove current Constrain and Try unchecking "Constrain to margins" button.

    Login or Signup to reply.
  2. You have an option on Xcode to vary your constraint depending of the size of the screen.

    You can create two constraints, one that works on iPad, one that works on "classic" iPhone.

    enter image description here

    Here, if I create a new constraint during the variation, I can then select on the right window which variation you want the constraint to be installed on.

    There is a whole topic about that here

    enter image description here

    Login or Signup to reply.
  3. 1- Give it a constant height for example 40

    2- While setting constraints, uncheck (Constrain to margins)

    3- Give it a proportional width constraint with the super view 0.8

    Note1: If you don’t want to give it a fixed height you can do the same step 3 but with height and not 0.8 but maybe 0.2 to less depending on your design.

    Note2: You can use a scroll view, it will make it so easy for you

    Login or Signup to reply.
  4. Try setting a constraint to a View instead of a SafeArea

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search