Search code examples
ioslandscapeuiinterfaceorientation

Why is my button not showing up in landscape mode?


I'm making a basic app in XCode but setting up all the components is giving me trouble, why will this button not appear in landscape mode?

My Layout


Solution

  • The way you are using Autolayout is the problem here. You are setting constants for the distances of bottom space and top space. When the device orientation changes, this leads to undesired results, such as that the button is not on screen any more.

    A better approach will be to position the views relative to each other. So, if you want the button to stay directly beneath the text field, you can set the vertical space of these two components instead of using bottom space for the button.