[英]stackview in custom table cell
In a custom table cell, I'm trying to hide/show view on a button click.在自定义表格单元格中,我试图在单击按钮时隐藏/显示视图。 I'm able to achieve this but couldn't able to remove the blank space.
我能够实现这一点,但无法删除空格。 How to remove those blank spaces.
如何删除那些空格。 I used auto constraints for stack view but it seems to be no use.
我对堆栈视图使用了自动约束,但似乎没有用。 can you anyone suggest a simple way to remove the blank spaces when the view is in a hidden state.
当视图处于隐藏状态时,任何人都可以提出一种简单的方法来删除空格。
Note: custom cell should adjust its height automatically depending on the content when it's attached to table view注意:自定义单元格在附加到表格视图时应根据内容自动调整其高度
Edit one编辑一
As you can see the start date and end date are placed at the bottom without any dynamic height change如您所见,开始日期和结束日期位于底部,没有任何动态高度变化
Preview of the custom cell.自定义单元格的预览。 In this Cell stack view at the bottom is set to hidden initially.
在此单元格堆栈视图中,底部最初设置为隐藏。
You have a couple options...你有几个选择...
1) Use another stack view: 1)使用另一个堆栈视图:
UIView
UIView
嵌入顶部的“始终可见”元素Now, when you hide the "sometimes hidden" stack view, it will not take up any space.现在,当您隐藏“有时隐藏”堆栈视图时,它不会占用任何空间。
2) Use multiple bottom constraints: 2)使用多个底部约束:
IBOutlet
- we'll call it whenHiddenConstraint
IBOutlet
- 我们将其whenHiddenConstraint
IBOutlet
- we'll call it whenVisibleConstraint
IBOutlet
- 我们将其whenVisibleConstraint
whenVisibleConstraint
to 750
whenVisibleConstraint
的优先级设置为750
whenHiddenConstraint
to 250
whenHiddenConstraint
的优先级设置为250
Now, in your code, when hiding the "sometimes hidden" stack view:现在,在您的代码中,隐藏“有时隐藏”堆栈视图时:
theStackView.isHidden = true
whenVisibleConstraint.priority = .defaultLow
whenHiddenConstraint.priority = .defaultHigh
when you want to show the "sometimes hidden" stack view:当您想显示“有时隐藏”的堆栈视图时:
theStackView.isHidden = false
whenHiddenConstraint.priority = .defaultLow
whenVisibleConstraint.priority = .defaultHigh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.