Why auto layout constraints not working?


I'm setting constraints in IB like <img alt="like shown in this image" class="b-lazy" data-src="https://i.stack.imgur.com/LuyGt.png" data-original="https://i.stack.imgur.com/LuyGt.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

But when i run the app on iPhone4 it shows <img alt="like this image" class="b-lazy" data-src="https://i.stack.imgur.com/NX0vv.png" data-original="https://i.stack.imgur.com/NX0vv.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Why last three buttons not shown properly on iPhone4 screen?is there any mistake in my constraints ? <strong>Edit:-</strong> This is my view hierarchy:- UITabbarControlle -> UINavigationController -> UIViewController and tab bar controller is rootviewcontroller.

<strong>Edit:-</strong> FYI there is no effect of any constraints on the screen(basically autolayout not working for me).


You have designed the buttons on 4 inch and you don't have enough space on 3.5 for all of them.

One way to do this is to place scroll view over your view controller's view and add the buttons on the scroll view.You have to add constraint on the scroll view , to be fixed on each side (without width/height).

<img alt="" class="b-lazy" data-src="https://i.stack.imgur.com/TrZ3Z.png" data-original="https://i.stack.imgur.com/TrZ3Z.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

After that grab all the buttons and add constrains on each side and sizes , so they will be fixed

<img alt="" class="b-lazy" data-src="https://i.stack.imgur.com/7aJUb.png" data-original="https://i.stack.imgur.com/7aJUb.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

If you , on other hand, have enough space for all the buttons to fit in 3.5' without any top/bottom margins you can add the button in UIView (instead of scroll view). Place the buttons in the view and set fixed width/height on that view.Center the view and it will keep his size (with the buttons inside on both screen sizes) <img alt="" class="b-lazy" data-src="https://i.stack.imgur.com/Nvqxt.png" data-original="https://i.stack.imgur.com/Nvqxt.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />


There is an issue in your constraints, you have to update them.

You can do as is shown on the image bellow:

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/d57sE.png" data-original="https://i.stack.imgur.com/d57sE.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Once done, you will see, the Orange lines under your buttons turned to blue.

I wish that helps you!


Your view is probably within a UIScrollView which will extend your total contentheight. It is not related to the absolute height of your viewport.

However, what do you expect? Your 3 buttons would overlay to the next buttons, if your theoretical approach would work.

What you need to to do is to wire all buttons to each other and give the view a top and bottom constraint to the top and bottom layout. You probably need to adjust your view to be on full screen and not to extend to the bottom.

Hint: as long as something is 'yellow' you need to add further constraints.


  • LeviCivita tensor in Sympy tensor package
  • get user node from Firebase using the uid in Android?
  • how to show gif image while uploading using jquery form plugin in asp.net mvc
  • Pandas corr() returning NaN too often
  • alpha and beta estimates for beta binomial and beta distributions
  • How can I implement Borrow for a generic container in the case of the use of associated types?
  • Viewing a PGP signature on a Maven artifact
  • How to call R functions from Fortran?
  • How to take the ln of a function in python?
  • MQL4, Code layout for big EA
  • R to BigQuery Data Upload Error
  • Tensorflow transform on beams with flink runner
  • Select running balance from table credit debit columns
  • how to submit mapreduce job with yarn api in java
  • Javapackager tool from command-line on OSX?
  • In Moment.js, how do you get the date of the next occurrence of a specific month (ex: 'next Jan
  • Pyinstaller GLIBC_2.15 not found
  • Passing HTTP Post from AWS API GW to Lambda
  • ASP.NET GridView throws: The version of SQL Server in use does not support datatype 'date'
  • How to select multiple items from a List view - JavaFX 8
  • How to use AJAX to upload large CSV file? [closed]
  • openpyxl - adding new rows in excel file with merged cell existing
  • How to split wav file into two or more parts using c#
  • Google Spreadsheet Script to Blink a range of Cells
  • How do I add a mouse over tooltip to an Image using .DrawImage()
  • Unity3d lost directional light shadows after generate assetBundle (.unity3d file)
  • Bad automatic Triangulation with Mayavi for coloring a surface known only by its corner
  • WPF custom control and direct content support
  • How to mutate multiple variables without repeating codes?
  • How to check if object is null in Java?