uistackview

How to make UIStackView scroll with UIScrollView programmatically?

耗尽温柔 提交于 2019-12-12 15:22:56
问题 I have seen several solutions to make UIStackView scroll with UIScrollView but they all rely Autolayout and IB. Is there a way to do it programmatically? I have seen this example: https://gist.github.com/twostraws/a02d4cc09fc7bc16859c But it uses Visual Format Language and I am using the Layout Anchor API. The layout anchor API: view.leadingAnchor.constraintEqualToAnchor(otherview.topAnchor).active = true 回答1: You can try ScrollableStackView : https://github.com/gurhub/ScrollableStackView

CGRectContainsPoint does not work on different views

心已入冬 提交于 2019-12-12 05:46:36
问题 I am making a simple drag drop project. When I use CGRectContainsPoint to drag a view and drop on different view it works. But both of the view should be in a same view. Now let's say I have a view called "A" and it contains two views. One UIView and one UIStackView . If I drag a view inside of Stack View to UIView it does not drop. Simply CGRectContainsPoint does not work for dragging and dropping from different views. Is there any way to solve it? 回答1: As each view has it's own coordinate

Dynamically add subViews to UITableViewCell

只谈情不闲聊 提交于 2019-12-12 03:06:39
问题 I need to add UILabels to UITableViewCell, but its dynamic, first cell can have 1 label, second can have 4 and I dont know before hand. So I tried this func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell { let cell: ReviewTableViewCell = reviewTableView.dequeueReusableCell(withIdentifier: "Review", for: indexPath) as! ReviewTableViewCell var reviewObj:Review! reviewObj = reviewArray[(indexPath as NSIndexPath).row] let viewsAdded =

Move visible images in StackView closer to leading space

你。 提交于 2019-12-11 23:46:42
问题 I have a horizontal ScrollView of 20 (110 * 130 point) UIViews contained within a StackView. Each UIView contains an image. When certain UIViews are hidden the UIView width is maintained at 110points. However, spaces are left were the hidden UIView should be. I have been practicing with a StackView of 3 UIViews and hiding the center UIView. This leaves a space in the middle... I would like the 3rd UIView to move into the 2nd UIView position (middle) and perform this for subsequent UIViews

UIStackView shift content to left when inner views are hidden

孤者浪人 提交于 2019-12-11 17:41:52
问题 I've 3 buttons inside a horizontal stack view. I want to shift buttons to left if one or two buttons are hidden. It's basically left shift operation. I've tried few options with stack view in storyboard but not sure if I'm on right track. How to do it in stack view or otherwise? 回答1: Update the stackview trailing constraint while hide the button. @IBOutlet weak var stackViewTrailing: NSLayoutConstraint! func hideButton(button: UIButton) -> Void { button.isHidden = true stackViewTrailing

UIStackView Autolayout constraints

淺唱寂寞╮ 提交于 2019-12-11 17:04:33
问题 I am creating a UIStackView with two buttons + & -. In the landscape mode the stackview it looks like this with vertical axis. And in portrait mode it has horizontal axis like this: Problem: Each button +/- is 50 points high. In landscape, I set w=50 & h=140 for the stack view whereas for portrait I set w=200 & h=50. I set the spacing property of UIStackView of 20 points in landscape and 100 points in portrait. I use 'Vary for Traits' to define different constraints for the two modes as well

Resizing UIStackView when hiding a subview?

北城余情 提交于 2019-12-11 15:25:52
问题 I have a UIStackView with the config below, when i hide its first subview i want it to shrink in height rather than redistributing the height of the existing cells to fill or leaving white space. Is there a way to achieve this? as currently it wont change in height despite hiding its contents let headerStackView = UIStackView() headerStackView.backgroundColor = .clear headerStackView.axis = .vertical headerStackView.alignment = .fill headerStackView.distribution = .equalSpacing

UIStackView within UIScrollView is cut off

雨燕双飞 提交于 2019-12-11 12:09:48
问题 I'm trying to use a UIStackView within a UIScrollView and I was hoping someone could point me in the right direction in creating the right constraints because I can't figure out what the problem is. These are my constraints and ViewController structure. So DestCont is a UIView that has a fixed height and ContentCont should take up the rest of the space, which could be (and is) larger than the screen so it should be able to scroll. When I test it out in the simulator, I have the following

Issues with UIPickerView inside a StackView

眉间皱痕 提交于 2019-12-11 10:29:25
问题 I'm running into a problem with the size of my pickers when I put them inside of a stack view. The pickers change their size to their default size when they are put into the stack view. They do not do this when they are not placed into the stack view 回答1: Just add height and width constraints to your picker before you add it to your stackview and that should solve your problem. 来源: https://stackoverflow.com/questions/32854074/issues-with-uipickerview-inside-a-stackview

Access nested stack views

不想你离开。 提交于 2019-12-11 08:39:51
问题 Obviously overseeing something simple. Need to access a nested stack view in another stack view. If I wanted to set spacing to all nested stackViews for passenger 2 how would I do that? // Select passenger 2 let tag = 2 // Select wrapper stackView for passenger 2 let stackView = self.view.viewWithTag(tag) as! UIStackView! let nestedStackViews = stackView. <-- WHAT GOES HERE?? for sv in nestedStackViews{ sv?.spacing = 0 // Set nested stackView spacing to 0 to avoid constraint issues } To