I am using Constraints in XCODE and I have a Slider in between a few buttons on my interface however whenever I try to "Pin" my Sliders leading and trailing spacing to the superview it never works. I need the slider to scale according to the left and right edges up my view but nothing works. Any idea or does anybody know something I don't about UISliders in Auto-Layout?!
Nevermind - DO NOT FORGET TO DELETE OTHER PINS IF YOU HAVE ANY ON THE SAME ELEMENT. Works great now.
:)
Related
This should be incredibly simple but somehow has proven incredibly complicated for me with auto layout.
I have a horizontal bar shaped button. I want to center a round information icon below it. Auto layout keeps trying to stretch the round button into an oval and is not centering it from left to right as in the following:
The above is the result of the following constraints that should work but don't.
Can anyone please tell me the correct constraints to add to accomplish this simple task.
Thank you.
If the image is being stretched, then set its contentMode to be aspectFit or aspectFill.
Once that is done, you can add a constraint to the image so that it and the login button share vertical centers.
Can you see this yellow box showing in your view? It's showing a warning that means the view which is selected right now should be placed here according to the defined constraints. I guess the constraints of this view are conflicting with other views. Try to resolve this warning by adding "suggested" constraints or by fixing misplacement. I hope it'll work, if not then give me your code I'll resolve that issue for you.
I'm trying to figure out how to use autolayout, and there seems to be a lack of info about it on the internet. I placed a view within my view controller with three buttons inside it. Before I place any constraints, the buttons show up on the preview. However, as soon as I make ANY constraints, the whole sub view completely stops showing up in the preview. I made a constraint to center vertically, and then one to place it 25 pixels from the left edge. It should know exactly where to place it, but still nothing shows up.
Any ideas on why constraints cause my buttons to not show up?
With Autolayouts the constraints should be as clear as possible. You can try by adding size constraints as well as fix(right, top or bottom) constraints if necessary.
When you don't use auto-layout it positions everything manually. When you enable auto-layout it switches this behaviour off so you have an unconstrained object, which is why it dissappeared.
Turns out I didn't have constraints on the size of the sub view, so it didn't know how to center it. I didn't think I needed that because I thought it would default to what it's already at.
I have UIViewController that contains UIPageViewController that contains UIScrollView.
- UIViewController
- UIPageViewController
- UIScrollView
-UIView (purple)
-UIView (orange)
And there is a problem. When I try to leaf page but not completely (staying on the same page) , there is overlapping of pages. Just look at this:
On the right. It a part from right page!
GitHub project:
https://github.com/maratsarbasov/Bug-or-not-XCode-6.1.1-
It is pretty simple (I specifically created it to show it to you). Please download it and compile.
Is there any way to get rid of this?
Thank you!
PS. Xcode 6.1.1. iOS 8.1 simulator. Using Auto Layout.
The problem is that your leading and trailing and top constraint of the scrollview are relative to the margin.
Uncheck relative to margin and set their constant to 0 this will fix your problem.
let me know if that works out.
Was having a similar problem but in my case it was because I was using 'Aspect Fill' in an image view. If you're doing that make sure you tick the 'clip subviews' checkbox to prevent the imageview breaking out of the page bounds
set clipsToBounds to true in your content view
I trying to align an UIView to the bottom of a container view(UIScroolView) and above a tool bar.
It works perfectly when design to the iphone 3.5 display but when a change my layout to the 4.0 display, my view doesn't get alined to the bottom instead it stays in the same position with a gap from the UIToolbar.
I checked and i realized the i have a constraint Vertical Space with a constant and i think thats why my view always stays in the same place, the problem is i can't get rid of this constraint, i'd like to know if someone could help me with this one.
thanks!
I think you need to add a height constraint to the toolbar. If you have that and a zero length vertical spacing constraint between the toolbar and scroll view, you should be able to delete that constraint to the top of the super view.
I'm having a heck of a time with using some of these constraints. I'm simply trying to add a UIView in the IB so that I can inject other views into as needed. However, I can not get the positioning right. No matter how many Constraints I add or remove I cannot seem to remove the 'Top Space to: Superview'. I'm simply trying to pin the UIView to the bottom and have it float up for the different screen sizes. This 'Top Space' is forcing the UIView off the screen and I can't seem to remove it nor de-prioritize it.
UIView Constraints (doesn't work) - sorry can't post images yet
http://i1322.photobucket.com/albums/u574/dneely79/uiview-constraints_zpscae66ed9.png
On another note though I can remove the UIView and add a UIImageView and I can get this to work. So, for now I'm actually injecting my views into this element instead of a UIView. Its working, just feels dirty.
UIImageView Constraints (Works)
http://i1322.photobucket.com/albums/u574/dneely79/uiimageview-constraints_zps726da545.png
Anyone else have any thoughts on how to overcome this? Its been driving me mad and doesn't seem to make much sense to me.
I've already tried this help link (though trying to anchor bottom and not top)
Xcode 4 and Interface Builder: Editing Vertical Spacing Constraint (Anchor Top, not Bottom)
Thanks ahead of time for any help or advice on this matter.
This was a semi-goofy mistake on my part based on the defaults that IB gives you. I went back and better analyzed my own pictures.
After noticing a height set on the UIImageView and not UIView, I added a height and was able to successfully delete the Top Space.