我试图添加tableview来查看控制器.一切都还可以,但页脚被隐藏/禁用?我不知道.
我的代码:
private let footerView = UIView()
footerView.backgroundColor = UIColor.Green.color
footerView.addSubview(activityIndicator)
tableView.addSubview(footerView)
tableView.delegate = self
tableView.dataSource = self
tableView.tableFooterView = footerView
tableView.sectionFooterHeight = 20
tableView.footerViewForSection(0)
tableView.tableHeaderView = footerView
Run Code Online (Sandbox Code Playgroud)
当然:
func tableView(tableView: UITableView, titleForFooterInSection section: Int) -> String? {
return "test.."
}
func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return footerView
}
func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 20
}
Run Code Online (Sandbox Code Playgroud)
我尝试了两个实现单独和没有(仅限空白).
并且我的页脚视图是浅灰色并且实现了活动指示器"不可见"(框架已设置)
它的ViewController与tableView.
任何想法,为什么页脚视图不可见?
谢谢.
我正在尝试处理 SwiftUI BarMark 中注释的点击
var body: some View {
List {
Chart {
ForEach(data) {
BarMark(
x: .value("Mount", $0.mount),
y: .value("Value", $0.value)
)
.foregroundStyle(by: .value("Type", "Series \($0.type)"))
.position(by: .value("Type", $0.type))
.annotation {
HStack {
Rectangle()
.fill(Color.red.opacity(0.2))
.frame(width: 20, height: 20)
.clipShape(Circle())
.onTapGesture {
print("Tapped!") // Never called
}
}
}
}
}
.frame(height: 250)
.labelsHidden()
}
}
Run Code Online (Sandbox Code Playgroud)
我还尝试了带有操作、图像等的按钮,但似乎注释中的所有交互都被禁用或者我不知道..
苹果提供了一些用于点击句柄的代码,但我不知道如何将其用于字符串(例如苹果有日期)并且没有像我一样的比较栏。
有什么想法吗?