ios - 使用代码快速堆栈视图隐藏和显示不起作用
问题描述
我正在按照文档“App development with swift”学习iOS应用程序开发,有一个示例“PersonalityQuiz”,我一步一步地学习。在一个视图控件中,有两个堆栈视图,都先隐藏,然后调用updateSingleStack方法如图所示显示堆栈视图:
func updateSingleStack(using answers: [Answer]) {
singleStackView.isHidden = false
singleButton1.setTitle(answers[0].text, for: .normal)
singleButton2.setTitle(answers[1].text, for: .normal)
singleButton3.setTitle(answers[2].text, for: .normal)
singleButton4.setTitle(answers[3].text, for: .normal)
}
但实际上什么也没有出现。
奇怪的是,如果我在 viewControl 中添加一个按钮,并添加一个 Action 来更改属性 singleStackView.isHidden,这个 stackView 会显示和隐藏。
请让我知道这是为什么?以及如何解决它。
谢谢!
解决方案
ok, During adding the singleStackView, and overlay another multipleStackView, the installed checkbox was unchecked, I thought it was the same as isHidden = true in the code. But it is not, after I check the installed checkbox for both StackView, now, the code works.
推荐阅读
- python - 在 Python 中使用多个条件进行排序的问题
- swift - 为什么默认命令只返回语法?
- c - 什么是递归函数的基本情况,它应该在字符串中找到数字的总和
- python - Pandas:将句点从“对象”类型转换为“句点”类型,以便能够进行计算
- api - 我找不到 tensorflow 的类 API DOC 参考
- azure-devops - 将 Azure DevOps 客户端库与 OAuth 一起用于长期 Web 会话的正确方法是什么?
- git - 尝试将代码提交到本地 Git 时出现 GradleException 错误
- c++ - 使用 C++ 通过 TCP 发送文件,接收错误的大小
- python - 如何将参数从以前的视图传递给表单?
- checkbox - 我怎样才能实现这样的输入复选框或单选按钮?