uistackview

How to add SubView to a horizontal StackView programmatically to create Stripes?

你。 提交于 2019-12-25 02:22:23
问题 I have a collectionView Cell with a StackView in it. class OuterCollectionViewCell: UICollectionViewCell { @IBOutlet weak var stackView: UIStackView! override init(frame: CGRect) { super.init(frame: frame) } required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) for i in 1...30 { let tick = UIView() if i % 2 == 0 { tick.backgroundColor = UIColor.red } else { tick.backgroundColor = UIColor.clear } tick.tag = i tick.heightAnchor.constraint(equalTo: self.heightAnchor, constant: 0

Cannot Set Programmatic Layout Constraints in UIStackView

痞子三分冷 提交于 2019-12-24 20:52:45
问题 I am trying to center radiobuttons in UIStackView that I have created via the storyboard. However, the radiobuttons are created within the UIStackView programmatically based on data in Firebase. I am using the library offered at DLRadioButtons. UIStackView below Label, named radioStackView: Code where Radio Buttons are added based on Firebase Data: ` pollRef.observe(FIRDataEventType.value, with: {(snapshot) in self.numberOfChildren = Int(snapshot.childSnapshot(forPath: "answers")

Custom UIView from XIB has no height in UIStackView

为君一笑 提交于 2019-12-24 15:24:50
问题 I am adding a custom UIView to a UIStackView inside a UIScrollView. The custom UIView is created from a XIB without a fixed width. I use autolayout to horizontally constrain the custom view to the UIStackView. All the subviews in the custom view have either a fixed height or an intrinsic height (i.e. labels). When I add the UIView to the UIStackView, they pile on top of each other, as if they have no height. How do I ensure the correct height of my custom view inside the stack view based on

How do I prepare a UIViewController's view for being added to a UIStackView?

久未见 提交于 2019-12-24 05:38:11
问题 This is what I'm trying to do... I have one view controller that needs to dynamically display different subviews based on the presence of some data. Here is a simple mockup. Each colored block represents a unique subview . Sometimes the green block needs to be at the top, sometimes the green block won't display at all, sometimes the light blue block will be something different, etc. Each subview has interactive elements, so I've been creating and adding them like so: Defining a new view

UILabel inside nested UIStackViews inside UITableViewCell sometimes truncating

天涯浪子 提交于 2019-12-24 00:59:12
问题 I have a tableview cell in one of my tables setup as containing the following view hierarchy The outer horizontal stackview is pinned to the cell's content view on trailing, leading, bottom and top edges. The right label is pinned to its parent stackViewHackView on trailing, leading, bottom and top edges Within my controllers code I've got the cells setup to be dynamic height to fit the content of the cells so they can grow or shrink depending on the content size tableView.rowHeight =

Xcode/Stackview, empty labels freaks out in stack view?

╄→гoц情女王★ 提交于 2019-12-23 15:17:25
问题 hopefully an easy one here. I have some labels and text fields. Between them, I want some empty labels, which will if needed to be error texts. But when I try to stack view it all, Xcode zooms out and nothing can be seen on the viewController. Anything else I need to change for it to work? You can see a picture of it here before I hit stack view: The email label and text field are already in stack view, so are passwords, gentag passwords and label/button. 回答1: This certainly appears to be a

Left aligned horizontal stackview and top aligned vertical stackview

孤人 提交于 2019-12-23 10:19:24
问题 I have two StackView , one of which is horizontal and another vertical. For the horizontal StackView, I want the items to be aligned to the left and grow toward the right. For the vertical StackView, I want the items to be aligned to the top and grow downward. For example the position of the top item would never change but the stackview expands down if another item is added. I'm having trouble accomplishing this, for example with my horizontal StackView, if I have two items 40x40, they will

CollectionView Disappears within StackView (Swift)

假如想象 提交于 2019-12-23 03:42:08
问题 I'm trying to achieve the stackView arrangement shown in the middle of this figure:, but for some reason the top stack, containing a collectionView, disappears when using: a .fill distribution stackView.distribution = .fill (stack containing collectionView disappears) stackView.distribution = .fillEqually (collectionView appears fine in stackView) I've been struggling with this for days, and you'll see residues in my commented out sections: setting compressionResistance/hugging priorities,

CollectionView Disappears within StackView (Swift)

断了今生、忘了曾经 提交于 2019-12-23 03:42:07
问题 I'm trying to achieve the stackView arrangement shown in the middle of this figure:, but for some reason the top stack, containing a collectionView, disappears when using: a .fill distribution stackView.distribution = .fill (stack containing collectionView disappears) stackView.distribution = .fillEqually (collectionView appears fine in stackView) I've been struggling with this for days, and you'll see residues in my commented out sections: setting compressionResistance/hugging priorities,

Drag and Drop Image from UICollectionView to UIView?

♀尐吖头ヾ 提交于 2019-12-22 05:43:12
问题 Is it possible to drag an image from a collectionViewCell into a UIView? I am creating a game where the user can pick a number of items to play with in the next VC. I'm representing each item as an image and the user can select each item by dragging the image to bottom of the screen. The image would then be reset to its original location. If I have the UICollectionView functions in my code, with the image selected in a class of UIViewCollectionView all set up correctly... What do I need to