how to get page transferred in swiftui button click action

how to get page transferred in swiftui button click action

Replies

Could you explain the context.


What is page ?

Transfer to what ?

Do you transition to another view ?


So, please take the time to explain what you want.


Typical code to pass String is:

import SwiftUI

struct ContentView: View {
    @State var destContent = "Some text to pass"
    var body: some View {
        NavigationView {
           NavigationLink(destination: DestView(passed: self.$destContent)) {
              Text("Press on me")
           }.buttonStyle(PlainButtonStyle())
        }
    }
}

struct DestView: View {
    @Binding var passed: String
    var body: some View {
        Text("Hello, World! \(passed)")
        //how to get back with buttom into the main view?
    }
}


In your case, you would replace the destContent String by the "page", whartever it is.