小编rob*_*ior的帖子

导航堆栈黄色警告三角形

我正在尝试监听布尔值的变化,并在听到成功后更改视图,但是会产生黄色三角形。我还没有设法查明问题,但它似乎与它正在转换的视图没有任何关系,因为即使更改后错误仍然存​​在。

我的代码如下

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)

xcode swift swiftui ios16

5
推荐指数
2
解决办法
2096
查看次数

标签 统计

ios16 ×1

swift ×1

swiftui ×1

xcode ×1