ios - UIStackview 在隐藏其中的标签时不调整大小

标签 ios swift xcode uistackview

您好,我是 UIStackViews 的新手。
所以我有一个包含 8 个标签的垂直 Stackview。
但是,我的 Stackview 的问题是,每当我将标签隐藏在其中时,我的 Stackview 都不会调整大小。

The labels within the Red Rectangle are in my Stackview
When I hide those labels of the Stackview, I want my screen to look like this
However for some reason when I hide those labels, it looks like this instead with all the space visible and the stuff at the bottom doesn't go up

我该如何解决这个问题?
这是我隐藏标签的方法:

 override func viewDidLoad() {
        super.viewDidLoad()
        showingResultLabel.isHidden = true
        addressLabel.isHidden = true
        costOfKitLabel.isHidden = true
        costOfModularLabel.isHidden = true
        dispatchedFromLabel.isHidden = true
        kitHomecostLabel.isHidden = true
        modularHomecostLabel.isHidden = true
        dispatchFromLabel.isHidden = true

谢谢

最佳答案

只需隐藏标签即可。您需要设置约束以使其工作。我上传约束图像。

enter image description here

stackview 的约束

enter image description here

关于ios - UIStackview 在隐藏其中的标签时不调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51461838/

相关文章:

ios - 出于某种原因尝试创建自定义 UITableView 和单元格显示条形图

ios - AKCallbackInstrument midiIn 和回调状态不起作用

ios - dyld:Xcode 更新后未加载库:@rpath/libswiftCore.dylib

ios - 是否有类似分页的代码用于将 JSON 数据保存到 Realmdatabase

ios - 具有 Cocoapods 依赖项的 Swift 项目

ios - 修剪视频而不显示 UIVideoEditorController?

objective-c - DDMath解析器 : Parsing formulas which contain if statements

ios - 在没有证书的情况下将客户端应用更新分发到应用商店

ios - 测试飞行 - 本地网络权限,TestFlight 构建中出现 NSBonjourServices 错误

ios - 如何在 Finder 中镜像项目的文件夹结构?