मैं कर रहा हूँ इस मुद्दे के साथ एक पत्र से पता चलता है कि एक सूची की पंक्तियों, तो जब एक पंक्ति दबाया है app करने के लिए जाना चाहिए एक और दृश्य/स्क्रीन (सी देखें) और पत्रक बंद कर दिया है, जो हो रहा है, लेकिन देखने/स्क्रीन पर popped है बाहर सही जा रहा है के बाद धक्का दे दिया.
आईओएस 15
देखें:
import SwiftUI
struct A: View {
@State private var showNewMessage = false
@State private var showChatView = false
var body: some View {
ZStack(alignment: .bottomTrailing){
NavigationLink(
destination: C(),
isActive: $showChatView,
label: {})
//NavigationLink(destination: EmptyView(), label: {})
ScrollView {
VStack(alignment: .leading) {
ForEach( 1...10, id: \.self){_ in
NavigationLink(
destination: C(),
label: {
ChatView()
})
}
}
}
Button(action: {
//showNewMessage.toggle()
showNewMessage = true
}, label: {
Image(systemName: "pencil")
.resizable()
.scaledToFit()
.frame(width: 24, height: 24)
})
.padding()
.foregroundColor(Color.white)
.background(Color.blue)
.clipShape(Circle())
.sheet(isPresented: $showNewMessage, onDismiss: test, content: {
B(showChatView: $showChatView, closeView: $showNewMessage)
}).navigationViewStyle(StackNavigationViewStyle())
}
.padding(.horizontal)
}
func test(){
print("Epale Debug: showChatValue: \(showChatView)")
}
func toggle(){
showChatView.toggle()
}
}
देखें बी:
import SwiftUI
struct B: View {
@Binding var showChatView: Bool
@Binding var closeView: Bool
//@Environment(\.presentationMode) var mode
var body: some View {
Button(action: {
//showChatView.toggle()
showChatView = true
closeView = false
print("Epale Debug: showChatValue: \(showChatView)")
//mode.wrappedValue.dismiss()
}, label: {
Text("Toggle")
})
}
}
P. S.: दृश्य C के लिए सिर्फ एक और देखने के लिए, और मैं पहले से ही जोड़ा navigationViewStyle(StackNavigationViewStyle()) के लिए संपत्ति NavigationView जड़ में फ़ाइल.