Stackview exchange or change order of views(Stackview 交换或更改视图顺序)
问题描述
包含文本字段数组的 Stackview 嵌入在滚动视图中.我想更改某些操作的文本字段的顺序.删除和添加文本字段的方式会导致视图失真.我还通过从滚动视图中删除进行了测试.正常的 stackview 也没有正确显示交换.我正在使用索引进行更改:
Stackview containing array of textfield is embedded in scrollview. I want to change the order of the text fields on some actions. The way to remove and add the textfield results in distorted view. I also tested by removing from scrollview. Normal stackview too the exchange does not appear properly. I am using indexes to change :
stackView.removeArrangedSubview(localityTF)
stackView.insertArrangedSubview(localityTF, at: 2)
推荐答案
这是一个奇怪的行为,但是自动布局系统有问题,应该在添加 localityTF 之前更新.另外不要忘记 removeArrangedSubview
不会从 subviews 数组中删除视图:
It is strange behaviour, but problem with the autolayout system, that should be updated before you can add localityTF back. Also don't forget that removeArrangedSubview
does not remove the view from subviews array:
[self.stackView removeArrangedSubview:_label1];
[self.stackView setNeedsLayout];
[self.stackView layoutIfNeeded];
[self.stackView insertArrangedSubview:_label1 atIndex:2];
[self.stackView setNeedsLayout];
这篇关于Stackview 交换或更改视图顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Stackview 交换或更改视图顺序


基础教程推荐
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- :hover 状态不会在 iOS 上结束 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01