uistackview

UIStackView - drag to reorder arranged subviews?

前提是你 提交于 2019-12-06 01:48:29
问题 I'm trying to get some advice on how to go about implementing the same sort of "drag to reorder" behavior found on a UITableView but on a UIStackView . So far this is what I'm thinking: Add a long press gesture recognizer to each of the arrangedSubview s On long press, add an overlay UIView as a subview to the main view and that fills the entire main view. This overlay view will act as a "canvas" of sorts as I'm dragging the temporary "reorder" view—we'll call this the tempView — around (more

how to programmatically reorder items within a UIStackView in IOS?

心已入冬 提交于 2019-12-06 00:00:34
问题 How can one programmatically reorder items within a UIStackView in IOS? (i.e. I can not see a function at https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIStackView_Class_Reference/#//apple_ref/doc/uid/TP40015256-CH1-SW30 to cover this)??? 回答1: surely you can use a combination of removeArrangedSubview(_:) insertArrangedSubview(_:atIndex:) to reorder your views? 回答2: When adding a view to a parent view, it is automatically removed from it's old parent view. This is the

First Baseline and Last Baseline Properties in UIStackView

ぐ巨炮叔叔 提交于 2019-12-05 14:01:30
问题 What effect does First Baseline and Last Baseline properties on the subviews of a UIStackView ? In fact, what does these property mean? 回答1: Suppose you have a two-line text view (or field or label or button) and a three-line text view, and you add them to a horizontal stack view. Do you want to align their first lines, or their last lines? That's the difference. .FirstBaseline : .LastBaseline : Note: I increased the vertical content hugging and compression resistance priorities to 1000

UIStackView and multi-line labels in a UITableViewCell

旧时模样 提交于 2019-12-05 12:18:59
I want to have a custom UITableViewCell with a number of vertically stacked UILabel s all of which can contain text that wraps multiple lines. With the new UIStackView in iOS9 and the cell self-sizing mechanism I thought this would be straightforward, but I can't get it to work. I am using Xcode 7beta3. I created a simple test app. This is the setup in IB: The UIStackView is vertical with UIStackViewDistribution.Fill and UIStackViewAlignment.Fill but I have basically tried all the combinations without success. The UILabel s have numberOfLines = 0 and lineBreakMode = .ByWordWrapping . The code:

UITextView added from code missing in UIStackView

会有一股神秘感。 提交于 2019-12-05 10:44:18
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: .Normal) button.setImage(UIImage(named:"image2"), forState: .Selected) textView.textAlignment =

height and vertical position are ambiguous for UIStackView

帅比萌擦擦* 提交于 2019-12-05 08:02:01
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. If this is for a UIStackView make sure you are using addArrangedSubview and not addSubview 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 checked "Hidden" in Interface Builder which meant Xcode was freaking out saying position and size are ambiguous.

Drag and Drop Image from UICollectionView to UIView?

老子叫甜甜 提交于 2019-12-05 06:04:29
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 include to move the image from top half (within CollectionView) to bottom half (within UIView). func

IOS-9 UIStackView issue in scrolling to leading edge

允我心安 提交于 2019-12-05 05:59:24
问题 I am trying to implement scroll for UIStackView where there are two buttons to add and delete views horizontally. I am changing the scroll.contentSize as the size of UIStackView so when the stack size is greater than the ScrollView's size, stack view can be scrolled. But while scrolling I am not able to reach to the starting of stack view. Few of my views in the beginning can't be reached while scrolling but last views can be reached. //In load view scroll = [[UIScrollView alloc]initWithFrame

How to Add Constraint for view inside stack view

谁都会走 提交于 2019-12-05 04:55:20
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 UIStackView's power is to reduce your using of constrains, just give it some setting info such as axis, distribution, alignment, spacing . stack view will layout your subview item

UIStackview align left

六月ゝ 毕业季﹏ 提交于 2019-12-05 04:36:50
I'm trying to align the items in UIStackview horizontally to the left. Is there anyway to do this programmatically? I tried to do this via storyboard but was not successful. For some reason, the items in the UIStackView centers itself. If you use StackView setting axis property to "Horizontal", I think you can't align it to the left. But there is a way to make it left visually. set StackView leading constraint with "equal" relationship set StackView trailing constraint with "greater than or equal" like this stackView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true