I'm trying to show a UITableView when a user presses the navigation bar button. My table view is built on the interface builder and I give it these constraints:
Trailing space to: superView.
Top space to: top layout guide.
Width.
Height.
(The table view should be at the top right side of the viewController's view when the user press at the button).
Now, I don't know why, but it works perfectly on iOS 8, but on iOS 7 the table is losing some pixels from the right (it slides outside from the view). I've noticed it can happen on labels too. Can anyone help me understand why?
In Xcode 6, the Layout Constraints are set against the Margin of the superview. That only works in ios 8 though. To get the old behavior, you need to select a constraint from IB, go to Attributes Inspector and see if the first or second item is set to margins.
For example:First Item: Superview.trailing Margin
Click on it and uncheck "Relative to margin". You will have to do that to all your constraints.
Related
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.
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.
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
iPhone View Hierarchy
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.
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
Remove current Constrain and Try unchecking "Constrain to margins" button.
Try setting a constraint to a View instead of a SafeArea
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
I'm making an app that supports 4s through to iPad (portrait only).
One view controller is set out roughly like this with these constraints:
http://i.stack.imgur.com/7tNlJ.png
The third button at the bottom when I launch on iPhone 4s can't be tapped.
Anyone have any idea why this might be?
I believe your problem is the bottom constraint of 128 pt on your bottom view. You should let your buttons drive the size of your bottom view. To do this, remove all constraints on the bottom view except for the align center to superview one.
Then, have your first and third buttons be tied to their superview through a top and bottom constraint respectively.
Also, have your first button be tied to it's superview with a leading and trailing constraints.
Finally, make sure all buttons have width and height constraints. And also, the second button should be tied to your first and last buttons, through top and bottom constraints, of course.
I am trying to make a universal app in Xcode 6 using swift, and it's not going so well. I have a tab bar controller app, and I am trying to make something like this:
(The height and width are set to Any) But when I run it on an iPhone 5 simulator:
How do I fix this? Will I have to make separate storyboards for each device?
I solved this issue by clicking on all of my items, then clicking on this guy near the bottom: Then clicking "Reset to suggested constraints".
What I understood is that, you should probably pin Top Space for the top most label and pin Vertical Spacing constraints for the other two buttons.
The "GO" button should have a vertical spacing constraint with respect to the "Control" label and the "STOP" should have a vertical spacing constraint with respect to the "GO" button or Bottom Spaceif you want to stick it to the bottom of the view.
I use autolayouts not for a long time and they often confuse me.
I have a wired constraints behaviour. I want to create a red view and make its margins 1/1/1/1. I tap a corresponded icon in the storyboard and set all fourth constraints to 1.
First of all values for left and right constraints are -16 and it's very strange. I have no idea where Xcode takes them.
I set all constraints to 1 and run my application. On the screen I see the view with top and bottom margins equal to 1 and right and left equal to 15.
And I have this behaviour always in every project. It very confuses me and don't give make UI correctly.
Does anybody know how can I avoid it? Everything I need it's say "Hey, Xcode, set margins for this view to 1/1/1/1" and the visible result will be the view with margins 1/1/1/1.
As usual, just after posing a question I've found a solution. When you set constrains turn the "Constrain to margins" checkbox off.
I'm struggling to get my constraints working for both ios 7 and 8 in xcode 6. My app is just a webview that should take up the whole screen and not appear under the status bar.
My problem is that it only displays correctly in either 7 or 8, but never both at once. Depending on how I adjust my horizontal constraints it's either too big for the ios7 screen and fits the 8, or too small on 8 and fits 7. Here's the issue and constrains I have set up:
*Edit: I think maybe my superview is positioned incorrectly, since my constraints are relative to the super view. I just can't figure out what would be wrong with it.
ios7 fits
too small on ios8 (green background is the parent UIView)
20point top constraint to move the view below the status bar
0 side constraint so it resizes on orientation change
0 side constraint so it resizes on orientation change
0 bottom constraint so the view isn't pushed below the bottom of the screen
I think you need to pin this webView like this
So apparently there were constraints on the parent view that I had the webview in. They did not show up in the left nav like the webview constraints did so I was not aware they were there. In the right inspector panel click on the ruler icon with the view selected and you'll see the constrains. After removing those it was just a matter of tweaking the constraints on the webview to align things properly.