swift - 标题重复,并且按钮在不完整的向后滑动时不起作用
问题描述
以制作代码为例。如果您对上一个视图进行不完整的滑动,那么在滚动的情况下,编辑器的文本开始与标题重复。即使没有@Environment
,我也检查了它,但是通过传输的isActive,但仍然是这个错误。此外,如果滑动不完整,按钮将停止工作。有人可以知道完整的 NavigationView 教程以避免一些错误吗?我需要标题不要跳,按钮很好。
struct View1: View {
@Environment(\.presentationMode) var presentationMode
var body: some View {
NavigationView {
ZStack {
Color.red
NavigationLink("View 2", destination: View2())
}
.navigationBarTitle("Back").navigationBarHidden(true).animation(.default)
}
}
}
struct View2: View {
@State private var texti: String = ""
@Environment(\.presentationMode) var presentationMode
var body: some View {
ZStack {
VStack {
TextEditor(text: $texti)
.padding().onReceive(texti.publisher.collect()) {
self.texti = String($0.prefix(2000))}
}
}
.navigationBarTitle("Your Title")
.navigationBarItems(trailing: HStack { Button(action:{}) {
Text("Ed").foregroundColor(Color(#colorLiteral(red: 0.3647058824, green: 0.6901960784, blue: 0.4588235294, alpha: 1)))
}; Button(action: {}) {
Text("S").foregroundColor(Color(#colorLiteral(red: 0.3647058824, green: 0.6901960784, blue: 0.4588235294, alpha: 1)))
}})
}
}
解决方案
推荐阅读
- r - 对于 R 包 MCMCglmm 贝叶斯回归中的先验定义,如何通过参数 nu 传达不同的相信强度?
- android - 如何使用改造多次调用具有不同数据的相同 API?
- java - 我怎样才能找到 id 元素的文本,使用 Java 的 css
- javascript - 细长的路由链接删除了电子中的基本路径
- python - 模块pafy(Python)的问题
- python - 使用 IPython.display.audio 在 jupyter notebook 中播放音频在函数内使用时不起作用
- java - Firebase 通过替换以前的数据来更新孩子
- flutter - Flutter I══╡ 图像资源服务捕获的异常
- java - 处理列表时 FasterXML 性能回归?
- bigbluebutton - Bigbluebutton 设置 - 生产环境的 ArgumentError 'secret_key_base' 必须是字符串类型