ios - 使 DisclosureGroup 不可扩展
问题描述
我在另一个 DisclosureGroup 中添加一个 DisclosureGroup 我希望第二个 Disclosure 组不可扩展(删除扩展能力)。这是可能的还是有更好的方法来实现这一目标?
@discardableResult
private func expand(key: String) -> Binding<Bool> {
return Binding<Bool>(
get: { expanded.contains(key) },
set: { isExpanding in
if isExpanding {
expanded.insert(key)
} else {
expanded.remove(key)
}
}
)
}
DisclosureGroup(isExpanded: expand(key: "Incomplete")) {
ForEach(Array(array), id: \.self) { key in
if let innerArray = innerArray {
// Make non expanable
DisclosureGroup {
ForEach(Array(tasks.enumerated()), id:\.1.title) { (index, check) in
// Content
}
} label: {
// Header
}
}
}
} label: {
// Header
}
解决方案
您可以创建一个常量Binding
集为true
. 这将使其永久扩展。
如果您希望它永久折叠(不确定为什么要这样),请false
改用。
DisclosureGroup(isExpanded: .constant(true)) {
// Content
} label: {
// Label
}
推荐阅读
- bash - 想在 Linux 服务器上生成一个长度为 15 个字符的随机密码
- java - Apache Kafka 中的“简单消费者组”是什么?
- python - ctypes在使用指向类对象的指针调用函数时出错
- api - 如何在 MVC .net 核心中获取具有基本身份验证的 api
- operating-system - 有时当我 ctrl+shift+i 时,结果为“í”,而不是打开检查元素
- python - 使用 if 条件时,Series 的真值是不明确的
- javascript - Vuejs加载CSS和JS文件给出MIME类型错误
- python - 如何让我的机器人响应用户提及?/如何制作 afk 命令?
- node.js - 如何在辅助进程中使用 Electron 遥控器?
- c++ - 模板参数推导编译错误