I have a button that needs to "stick" to the bottom of the main view on both 3.5 inch and 4" iPhones. Currently, I can move it right to the bottom of the storyboard on a 3.5" view but then on a 4 inch view, it moves up.
How do I stick the button to the bottom of the view on both screen sizes?
Select your button which you want to pin to bottom. Click on add new constraints and select bottom constraints then click on add.
Use AutoLayout feature.
While you're laying UI components on the screen, you see some blue colored guidelines, those are just helper lines and have no effect whatsoever when you actually run the program.
Once you're done with placing all the UI components on the screen, you have to actually set the constraints for the AutoLayout using the few buttons that are placed in the bottom right part of the Storyboard view.
Is suggest that you right click on the Storyboard view, and go into "Interface Builder Help" option, and then click on "Understanding Layout Constraints" and "Aligning and Pinning Objects" to see how constraints are actually set.
Related
Please take a look at screen shot from simulator for iphone 8 plus. (01.png) Here is my question: I cant see whole view of my page(i cant see whole part of button5 and button6 because there is no vertical scroll bar) Shouldn't vertical scroll bar appear automatically? If vertical scroll bar appears then i can reach bottom of the page. What should i do? Please give me an advice because i haven't founded any solution yet. You can also take a look at screen shot from xcode main story board to see height of button5 and button 6. (02.png) I mean page background should not move. But I should be able to scrolling up and down through on page. Thanks.
01.png
02.png
Just add image view with background image below all components in the ViewController.
Then add Scroll View with your content on top of that image view.
Don't forget to select clear colour as the background for scroll view and the inner view apart from your buttons.
Follow this tutorial to add Scroll view and content in it directly in storyboard using Interface builder.
https://medium.com/#pradeep_chauhan/how-to-configure-a-uiscrollview-with-auto-layout-in-interface-builder-218dcb4022d7
I am working on IOS app which got a UITabeView. I needed custom UITableViewCell, so i created .xib file to design it and linked it to my custom class. But I want a button to be aligned right and I cannot achieve it. The screenshot below shows my problem:
I am using autolayout. On the left side I have my .xib opened where I have a button. In the middle there is a simulator which show only a part of a button. Moreover, If a change orientation, absolute button position doesn't change (it becomes fully visible). On the right side you can see how I set constraints. Obviously, I did it in a wrong way, but I've tried everything and nothing helped. Different constraints, values, toggled autolayout - no effect.
How do I set up constraints so that my button is aligned right (on both orientations)?
P.S. I am using Swift.
you have to link your button to the view which contains it, you can press Ctrl and drag the mouse from your button to the view which contains it, Xcode will show a menu with the available constraints:
You have to select the constraints you need for setting up the position of the button, in your case it will be leading space to container, and in addition you should select width and height constraints. For selecting those constraints you can press this button on the bottom of the screen:
and in the following menu select the width and heigth constraints:
Hope it helps!
So I'm creating my app in storyboard, and i'm using an navigation controller, added an add view, and trying to auto layout stuff there.
But the problem is, i only get blue guided lines when I'm near the corner left and right. So it's basically not looking at my Navigationbar above.. and just ignoring it.
Also, when I'm switching the simulator to a 3.5 inch (I'm making it in 4 inch) the buttons and labels will disappear underneath it. And they are added to Auto layout blue lines?
The blue lines are not AutoLayout, but just lines that guide you when placing your views. Auto Layout only comes in when you start adding constraints. Check out Apple's Autolayout guide:
https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html
Control drag from the label to the navigation bar and it will show the below window. The first option is for you to create the constraint from the Navigation Bar bottom.
The Top Layout Guide is a iOS 7 specific feature which marks the bottom line of the navigation bar. The total height of the navigation bar (if present) plus the height of the status bar (if present) equals the toplayoutGuide.length
I have UITabBarController based iPad app with containerView on the first tab. The containerView has standard vertical spacing to bottom layout guide. When I tap on the second tab and then go back to the first tab, my container moves down by 56 pts, the height of the tabBar and is then covered by the tabBar.
I made 3 screenshots to illustrate that. The third screenshot shows hidden tabBar after the jump between tabs. It looks like the bottom layout guide went down to the edge. What is going on here?
I'm not sure about what happened here, but I think that this could help:
Uncheck Under bottom bar in your UIViewController properties
Hope that will help!
Nicolas Bonnet's answer of unchecking "Extend Edges Under Bottom Bar" didn't work for me. In my case the problem seemed to be that I was setting the bottom constraint of my view equal to the Bottom Layout Guide.
So, instead, I aligned the bottom edges of my button and the ViewController's view as shown below.
Select both your view to pin to the bottom and the main view:
Then tap the Align selection menu at the bottom right of Interface Builder and select Bottom Edges:
I am doing a simple one view layout, calculator style app. I have multiple input fields, where values are entered, and a calculate button. All this works well. When I change size to 3.5" screen, the iAd banner I have at the bottom of screen disappears. When I switch back to 4", the banner is back. How do I lock down the banner to display at bottom of screen regardless of screen size? Thanks~
Hopefully you're using Autolayout. It takes a while to understand, but when you do it is extremely powerful for laying out flexibly for multiple screen sizes.
Anyway, assuming you are using Autolayout:
Here's my ViewController with the banner ad at the bottom
I select the banner and then click "Pin" - I then add the constraints that you can see in the image - click "Add Constraints".
Now, if I view how it would look on a 3.5" screen, it is still fixed to the bottom.
This can be happening because the Autolayout. Go to Storyboard, select the iAd view, then click on the segment "Pin" (third button on the bottom of Storyboard) and add the bottom Constrain.
Hope it helps.