swift - 动态关闭工作表错误后无法单击 NavigationBarItems?
问题描述
我有 NavigationView 和 NavigationBarItems 按钮。Button 调用一个工作表,我通常可以通过向下拖动来关闭该工作表,然后通过单击一个按钮再次打开该工作表。
问题:如果我在工作表内单击按钮退出面板,则无法再单击面板上的按钮。
struct ContentView: View {
@State private var showSheet = false
var body: some View {
NavigationView {
Text("Hello World")
.navigationBarTitle("Mapp")
.navigationBarItems(trailing: Button(action: showSheetFunc) {
Image(systemName: "plus").padding(5)
})
.sheet(isPresented: $showSheet) {
SheetView(showSheet: self.$showSheet)
}
}
}
private func showSheetFunc() {
self.showSheet = true
}
}
struct SheetView: View {
@Binding var showSheet: Bool
var body: some View {
Button(action: { self.showSheet = false}) {
Text("Close Me")
}
}
}
我制作了一个视频来说明这个问题。最后,当我单击按钮时,什么也没有发生。
解决方案
为您的按钮图像添加更多填充,例如:
Image(systemName: "plus").padding(20)
推荐阅读
- git - Git:将文件从一个存储库复制到另一个(不相关的)存储库
- android - 删除自定义列表视图中的多个选定项目不适用于 ImageButton
- node.js - 使用 express post 方法在 db 中插入新数据
- node.js - 温斯顿没有记录未捕获的异常
- python-2.7 - WindowsError: [错误2] 创建子进程时系统找不到指定的文件
- c++ - OpenSSL RSA 解密随机失败 C/C++
- php - 如何在 Laravel 中更改错误消息标题是必需的
- sql - SQL查询根据日期和月份检索用户
- ios - ViewModel 类能否按照 MVVM 在 iOS 中符合 UITableviewDelegate 和 UITableViewDataSource
- python - 重新采样每日数据以获得每月数据框?