How to set width of view to be half width of its superview in Xcode 6 - interface-builder

Trying to understand autolayout in Xcode6/Interface Builder.
How can I set the width of a view to be half (or like 10% or whatever) width of its superview in Xcode 6/Interface Builder using constraints?

Related

Need constraints for: Y position or height, Scrollview including Imageview

It gives me the following warning: Need constraints for: Y Position or height. I can get it working with for example TextView, by disabling "Enable Scrolling" but ImageView does not have a setting for something like that. I've also tried selecting my view controller and enabling/disabling "Adjust Scroll View Insets" which gives no results.
EDIT Image of my hierarchy.
The layout is ambiguous, because AutoLayout does not know the height of your UIImageView instance. Constraining views against a UIScrollView is somewhat special, because the ScrollView's contentView needs to calculate it's size based on the subviews. To to this AutoLayout needs to be able to calculate the dimensions of all the subviews without relying on the ScrollView's size.
There are different ways to solve this.
Add a explicit height constraint to the imageView
Add a aspect ratio constraint to the imageView
Set a placeholder intrinsic content size in the Interface Builder

In xcode, UIStackView height not changed

I put multiple UIView in UIStackView.
But, When I set the UIView's height under 50, the UIView's height is changed automatically to 50!!
I don't set any constraints into UIViews and UIStackview.
How can I solve this problem?
stackview screenshot
fixed height image screenshot

How to automatically grow width of NSTextField as per content but only until certain width?

I have a NSTextField. I want it to grow in width and height. However the NSTextField is inside a view. I don't want the text field's width grow beyond 60% of its super view. Once the width has reached 60% width of superview I want the text field to increase in height. Is there anyway I can achieve this using storyboards? Basically the text field is basically a subview of NSTableCellView. So I want the text field to adjust it's height whenever the table view is resized.

Scrollview in Interface Builder with Autolayout with content size dynamically set to screen size?

I want to set the content view of a scrollview to whatever the current screen size is, but AutoLayout is doing some funky stuff. This is trivial in code... just create a scrollview with a frame that is the superview's bounds. Then create a content view with the scrollview bounds and populate it and set the alwaysBounces... properties to YES. In interface builder though, this is some kind of sinful thing it seems.
I know Autolayout handles scrollviews totally differently because it wants to infer the content size based on constraints. My approach that failed is setting the scrollview to have 0 distance to its superview (all sides attached). Then, the same with the content view (the single scrollView subview)- attached to all superview edges. Then the precompiler thing complains about not knowing the content size, so I set a width and height constraint at placeholder to be removed at build time. But the result is a (CGRect){0,0,0,0} contentView. The 0 space to trailing edge and bottom of superview are totally ignored.
So how can I make a scrollview with a dynamic content size based on the screen size?
Bonus points if you can explain how you would do the same, but for a content size of 2x screen width.
You can try setting a constraint for the content view's width to equal the scroll view's width (for your bonus question: with a multiplier of 2). Same for height.
Not sure what the point of having a scroll view whose content is always the size of the scroll view is. By definition it wouldn't scroll, right?

Why view size is 703x768 for iPad app in Interface Builder?

Im working on my first iPad app.
By default Xcode generated for me a starting point project, which contains the basic template for the Split view controller.
I am focusing on the detail view controller right now (my first app version may only utilize this view).
Anyway, I noticed that in the Xcode integrated Interface Builder the detail view is 703 (width) x 768 (height).
First question: why is the width 703?
Now, the view in the IB shows a portrait layout of the view. So it's even more odd that the width is greater than the height (when it should be the other way around).
I actually expected the width to be 768, and the height 1024.
updated *
2nd Question: In portrait mode, why is the width 1024 and height 768 (see above closing comments).
Thanks.
The split view's master is 320 px wide according to the documentation, leaving the detail pane a comfortable 768 or 704 px wide depending on the orientation of the device.
ref> ipad split view dimension parts
Please take a look here

Resources