I pinned a UIImageView to 0 in all four directions, but it stays the same and doesn't pin to the edges, how do I fix this?
I bet it has something to do with your content mode of the UIImageView. Try changing it in your storyboard or in code and find a style that suits your need.
I think you can to resolve it by Using Reset to suggested constraints Easily.How about dragging UIImageView edges to main UI edges and then reset to suggested constraints?
Related
I am trying to place a circular imageview on top of another imageview something like in the picture. Does anyone know how i can achieve it.
In storyboard, you can do it by setting circular image align bottom to image view with half size of your circular image. In my case circular image's height is 100 so, it's half is 50. Please see following image for detail.
Hope this help!
you should give center vertical constraint and then open constraint property and change first item or second item (as per your requirement) center y to top option Like
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 have a UIView and inside that there is a subview which is UIView again, inside that UIView i want to add a UILabel at the centre , I am using Autolayout. I have added all the constraints to all the views , but UILabel at the centre is only visible on iPad screens, it goes missing on smaller screen, my doubt is, when its coordinates, when are calculated on resized parent UIView, turns out to be wrong or it gets squeezed so much that it becomes invisible.
Please help me on this, I am not an expert in auto layout so obvious.
Thanks
Also the outer UIView will be presented fullscreen in parent ViewController
These are my constraints
And this is my Layout in all screens
Where your label is centered and also the Black View is increasing height with aspect ratio as per the device's height
set leading,trailing,horizontal center in container and top constrain to label with it's container view.
You should align it horizontally in the container.and also no one will be able to help unless you show all the constraints.
I really hate to ask here because I usually try to figure things out on my own. But on this one I've stuck for days and can't find a solution anywhere online.
I have a ScrollView containing multiple subviews. I've got an image view and two labels at the top with fixed heights. Then there is a UITextView and another ImageView (see pictures).
I add the text to the text view programmatically so it should have a dynamic height and the ImageView should move to the bottom so you can scroll. I don't want the TextView to be scrollable in itself but I want all the subviews to move as well.
I know I should be able to solve this issue using constraints. But I feel like I've tried everything and nothing worked yet. It worked when I disabled auto layout and moved the views manually. I'm wondering if there is a better way though.
As you can see I pinned the TextView to the ImageView above with a 1,000 priority and to the ImageView below with a 1,000 priority. The height constraint can not be deleted so I set it to the lowest possible priority. The ImageView on the bottom is pinned to the bottom of the superview with an absolute height. Its height constraint also has low priority. (I can post an image of the ImageView's constraints, if it helps)
I also tried adapting the frame programmatically but this is not working well in combination with auto layout. (If it helps I can of course post the code)
What am I doing wrong? Shall I just disable auto layout and do it manually? This seems unclean to me. Is it even possible to do?
I really appreciate your help :)
Greets,
Jan
Make sure the Scrolling Enabled attribute on the UITextView is unchecked in Interface Builder. I believe that the Auto Layout system takes that into account when it calculates the intrinsic content size.
If somebody is struggling with a similar problem: This is what I ended up doing:
Remove all subviews from the ScrollView in IB
Programmatically add a single UIView to the ScrollView.
Add all the views to the UIView as subviews (move them using setFrame)
Set the Frame of the UIView appropriately to the subviews
Set the ScrollView's contentSize to the size of the UIView.
A little more work but it finally works. This follows Apple's mixed approach guidelines that can be seen here (look for UIScrollView): http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/index.html
The problem is the height setting. You somehow have to try to delete it. If you have added other constraints that are "sufficient", it should become deletable.
At the moment you have one user constraint for the height that is "Greater or equal" and an "Equals" constraint as well. Clearly, those are not working well together.
Maybe there is a conceptual error as well. The lower image view should not be fixed in position, so the distance to the lower image view will not be a "sufficient" constraint to let you delete the fixed height.
I think it should work if
the lower image view has a fixed height and
a fixed distance to the text view above, and
the text view has a minimum height as well as
a fixed distance to the image view above
(which should be fixed in relation to the superview).
I'm recreating my UI with auto layout and have a navbar across the top and a 2x2 grid of UIImageViews filling the rest of the screen. I put in all the constraints so it maintains this arrangement in any orientation and it's working well when the UIImageViews don't have an image in them. When I programmatically load an image in the UIImageViews, they change size and placement even though I have constraints that should prevent this.
I have all the autoresizing masks off for everything and the UIImageViews set to Aspect fit.
This autolayout stuff is new to me, but I thought I had it working...until I put an image in there. Why would that change the size and placement of the UIImageViews?
Thanks for the help!
You can modify contraints at runtime if you link them with an outlet in your view controller.
For your case you would add a width and height constraint and link them to two outlets.
Then after you know the image dimensions you would change the constant value.
I am describing this in detail for a similar use case I had here: http://www.cocoanetics.com/2012/11/first-good-auto-layout-use-case/