我正在尝试监听布尔值的变化,并在听到成功后更改视图,但是会产生黄色三角形。我还没有设法查明问题,但它似乎与它正在转换的视图没有任何关系,因为即使更改后错误仍然存在。
我的代码如下
import SwiftUI
struct ConversationsView: View {
@State var isShowingNewMessageView = false
@State var showChat = false
@State var root = [Root]()
var body: some View {
NavigationStack(path: $root) {
ZStack(alignment: .bottomTrailing) {
ScrollView {
LazyVStack {
ForEach(0 ..< 20) { _ in
Text("Test")
}
}
}.padding()
}
Button {
self.isShowingNewMessageView.toggle()
} label: {
Image(systemName: "plus.message.fill")
.resizable()
.renderingMode(.template)
.frame(width: 48, height: 48)
.padding()
.foregroundColor(Color.blue)
.sheet(isPresented: $isShowingNewMessageView, content: {
NewMessageView(show: $isShowingNewMessageView, startChat: $showChat)
})
}
}
.onChange(of: showChat) { newValue …Run Code Online (Sandbox Code Playgroud)