uistackview

UITextView added from code missing in UIStackView

↘锁芯ラ 提交于 2019-12-07 06:05:38
问题 I'm trying to add a UITextView to UIStackView programatically, but it doesn't appear on the screen. When I check in Debug View Hierarchy, it is in the view hierarchy and it has some constraints but doesn't show up in the outputted view. This is my code: let stackView = UIStackView() let textView = UITextView() let button = UIButton() stackView.axis = .Horizontal stackView.spacing = 20 stackView.distribution = UIStackViewDistribution.Fill button.setImage(UIImage(named:"image1"), forState:

Swift: UIStackView of UIControls with selector method that doesn't fire

风流意气都作罢 提交于 2019-12-07 04:44:09
问题 Introduction I'm creating an app which uses a custom view in which I have a UIStackView to sort out 5 UIControls. When a user taps one of the UIControls an underscore line gets animated, sliding under the tapped UIControl. However, for some reason the method/selector for these UIControls no longer gets called. I believe this has to do with that I updated my Mac to the macOS (and Xcode) update released this week (wk.44). (updated from swift 4.2 to swift 4.2.1). Before the updated this

height and vertical position are ambiguous for UIStackView

孤者浪人 提交于 2019-12-07 03:22:30
问题 Autolayout cannot figure out the height or vertical position of a UIStackView despite having added subviews. This is a pretty common error and "gotcha" so please see the answer below. 回答1: If this is for a UIStackView make sure you are using addArrangedSubview and not addSubview 回答2: For me I received the following error: warning: Ambiguous Layout: Position and size are ambiguous for 'Button'. Where the button was placed inside a stack view in Interface Builder. The problem was that I had

How to Add Constraint for view inside stack view

谁说我不能喝 提交于 2019-12-07 00:12:02
问题 I have one stack view that contains with 4 buttons. And each button I also add subview to that. The subview of that 4 buttons, I try to program to add constraint into it. Some constraint such as .Trailing .Leading .Top .Bottom I cannot add to it by error constraint and stack view problem. How any solution to add that constraints to subview of stackview. if have any sample it's really good for me. thank in advance 回答1: UIStackView's power is to reduce your using of constrains, just give it

Animating UIStackView arrangedSubview content size change

╄→尐↘猪︶ㄣ 提交于 2019-12-06 23:57:00
问题 Is it possible to animate an arranged subview when its intrinsic content size changes? For example, imagine I have an arranged subview, which holds a single UILabel pinned to edges. That label has a small amount of text. New text comes in, which is larger than the previous text. The intrinsic content size of label is now larger. I would like to be able to animate it like so: stackView.layoutIfNeeded() self.label.text = self.expanded ? textTwo : textOne UIView.animateWithDuration(0.3) { () ->

Unresponsive UIButton in subview added to UIStackView

我是研究僧i 提交于 2019-12-06 20:18:25
问题 In the detailViewController of a UISplitView I have subviews added to a UIStackView inside a UIScrollView . Just using system buttons without subviews or images , results in responsive buttons, but subviews seem to interfere. Enabling touch is specifically coded. I have attempted to keep each view inside the containing view so there will be no overlap to invalidate receiving touch events, but not sure if this is done properly. Each subview contains a label and a custom button with an image.

Swift: Bring View from Stack View to front

别来无恙 提交于 2019-12-06 12:11:43
问题 I got a Stack View with view: 1,2,3,4 and 5 Looking for a method to bring the Image View4 from view4 in the Stack view, above all the other views. The reason I need this is because I am moving the Image View4 over the Image View3 in view3. I have tried to move view3 over view4 in the view hierarchy, but that just swaps their places in the Stack View. 回答1: From the UIStackView documentation: The order of [the views in] the subviews array defines the Z-order of the subviews. If the views

Retrieve the right position of a subView with auto-layout

橙三吉。 提交于 2019-12-06 11:25:41
I want to place programmatically a view at the center of all the the subviews created in a storyboard. In the storyboard, I have a view, and inside a Vertical StackView, which has constraint to fill the full screen, distribution "Equal spacing". Inside of the Vertical Stack View, I have 3 horizontal stack views, with constraint height = 100, and trailing and leading space : 0 from superview. The distribution is "equal spacing" too. In each horizontal stack view, I have two views, with constraint width and height = 100, that views are red. So far, so good, I have the interface I wanted, Now I

How to center both vertical and horizontal inside a UIStackView

五迷三道 提交于 2019-12-06 03:20:51
问题 I have a simple UIImageView with 50x50 size . If I had a UIView of size 100x100 and I wanted to center the image inside of it, all I have to do is set these But how do I do the same with a UIStackView of size 100x100 ? EDIT i think i should have been more clear. The questions is, how do i center the image both vertically & horizontally inside of the UIStackview ? 回答1: Use two stack views. Vertical stack view with centre alignment. Inside that is a horizontal stack view with centre alignment t

Create Vertical lines between Uilabels inside of a stack view [duplicate]

人走茶凉 提交于 2019-12-06 01:53:57
问题 This question already has answers here : iOS - Add vertical line programatically inside a stack view (6 answers) Closed 2 years ago . I want to create a UICollectionView with a custom header in Code. Therefore i created a Subclass of UICollectionViewCell to describe my custom header. I want to display five labels in my header in a horizontal line. Therefore I created five labels and add them inside a stackView. The stackview show my labels filled equally. So far everything perfect. Label1