autolayout

Autoresizing not working in iOS11 / XCode 9

孤街醉人 提交于 2019-12-20 14:06:39
问题 It appears that the Autoresizing of views is no longer reliably working when building for iOS11 with XCode 9. The layout of several views end up with the positioning of controls as they are in the XIB, but the appropriate resizing has not happened. This has been working fine in iOS10, and works with our old app running in iOS11. However, rebuilding the app the positioning and sizing fails. Has something changed that impacts the use of autoresizingmask ? Is there a way to automatically convert

Centering View between neighbors using autolayout in IOS

心不动则不痛 提交于 2019-12-20 10:37:22
问题 I am attempting to layout a screen design using constraints (auto-layout) from interface builder and hope to avoid coding constraints, but I would accept an answer for either case I guess. I have two subviews in a contained in a top level view. I want to fix vertical distance of the first subview to the top of the screen (I was able to accomplish that - common use case for a vertical space constraint). I want the second subview to float (vertically) in the center of the distance between the

Repositioning controls when the orientation changes

不问归期 提交于 2019-12-20 10:35:19
问题 I know Auto Layout can be used to make the sizes and position consistent when the orientation changes. Is it possible to completely change the layout when the orientation changes? For example, please look at the below wire-frame of a simple login screen in portrait mode. Now if I rotate the device, I want to completely re-position the controls. Can this kind of a thing be done by using Auto Layout? If not, how should I go about this? Thank you. 回答1: In your case it can be achieved by two

Difference between NSLayoutAttributeLeft vs NSLayoutAttributeLeading

一个人想着一个人 提交于 2019-12-20 10:28:53
问题 What is the difference between NSLayoutAttributeLeft and NSLayoutAttributeLeading in iOS autolayouts? 回答1: "Leading" does not always mean "Left". For RTL-written languages (locales) leading edge of the object’s alignment rectangle will be located at the right side of the object. Quote from Auto Layout Guide: The attributes leading and trailing are the same as left and right for left-to-right languages such as English, but in a right-to-left environment such as Hebrew or Arabic, leading and

Autolayout height equal to MAX(multiple view heights)

僤鯓⒐⒋嵵緔 提交于 2019-12-20 10:03:50
问题 Say I have a view called container . container contains 5 UIButtons . I want to add a height NSLayoutConstraint on container , and this height should be equal to the NSLayoutHeightAttribute of the tallest button in its subviews. I don't see a straightforward way to do this. Anyone have any ideas? 回答1: You need one constraint for each subview (button), specifying that the container's height should be greater than or equal to the subview's height. Give that constraint a high priority, like

NSSplitView and autolayout

纵饮孤独 提交于 2019-12-20 09:49:35
问题 How should I use auto layout constrains inside NSSplitView subview? My NSSplitView subview has 3 subview: topPane , tableContainer and bottomPane and I set the constrains like this: NSDictionary* views = NSDictionaryOfVariableBindings(topPane, tableContainer, bottomPane); for (NSView* view in [views allValues]) { [view setTranslatesAutoresizingMaskIntoConstraints:NO]; } [myView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[topPane(34)][tableContainer][bottomPane(24)]|"

Using Autolayout Visual Format with Swift?

寵の児 提交于 2019-12-20 09:47:19
问题 I've been trying to use the Autolayout Visual Format Language in Swift, using NSLayoutConstraint.constraintsWithVisualFormat . Here's an example of some code that does nothing useful, but as far as I can tell should make the type checker happy: let foo:[AnyObject]! = NSLayoutConstraint.constraintsWithVisualFormat( format: "", options: 0, metrics: {}, views: {}) However, this triggers the compiler error: "Cannot convert the expression's type '[AnyObject]!' to type 'String!'". Before I assume

Nested UIStackViews Broken Constraints

人盡茶涼 提交于 2019-12-20 09:30:57
问题 I have a complex view hierarchy, built in Interface Builder, with nested UIStackViews. I get "unsatisfiable constraints" notices every time I hide some of my inner stackviews. I've tracked it down to this: ( "<NSLayoutConstraint:0x1396632d0 'UISV-canvas-connection' UIStackView:0x1392c5020.top == UILabel:0x13960cd30'Also available on iBooks'.top>", "<NSLayoutConstraint:0x139663470 'UISV-canvas-connection' V:[UIButton:0x139554f80]-(0)-| (Names: '|':UIStackView:0x1392c5020 )>", "

Center custom UIView vertically and horizontally using Auto Layout

坚强是说给别人听的谎言 提交于 2019-12-20 09:22:11
问题 I'm trying to build a rather simple animated custom UI using the Auto Layout API newly available iOS 6. The custom view I'm building has a circle that I want to be both vertically and horizontally centered. Unfortunately I can't figure out why my constraints appear to work fine for UIButton, and UILabel elements but yield weird results when I use a custom view with and custom CALayer (in this case a circle, that will eventually be animated). To be clear I don't want my view to expand to fill

AutoLayout row height miscalculating for NSAttributedString

泄露秘密 提交于 2019-12-20 09:07:11
问题 My app pulls HTML from an API, converts it into a NSAttributedString (in order to allow for tappable links) and writes it to a row in an AutoLayout table. Trouble is, any time I invoke this type of cell, the height is miscalculated and the content is cut off. I have tried different implementations of row height calculations, none of which work correctly. How can I accurately, and dynamically, calculate the height of one of these rows, while still maintaining the ability to tap HTML links?