Piakkaa
Piakkaa

Reputation: 818

How to customize swiftui file exporter to show save instead of move

I would like to allow user to export a text file and save it to their filesystem. However, swiftUI shows a button that says move in the popupview instead of save. how can I change that behavior.

enter image description here

struct FileExporterDemo: View {
    @State private var showingExporter = false

    var body: some View {
        Button("export"){showingExporter = true}
        .fileExporter(isPresented: $showingExporter, document: TextFile(initialText: "test"), contentType: .plainText) { result in
            switch result {
            case .success(let url):
                print("Saved to \(url)")
            case .failure(let error):
                print(error.localizedDescription)
            }
        }    }
}

Upvotes: 5

Views: 738

Answers (1)

Nav Brar
Nav Brar

Reputation: 384

iOS doesn't allow us to change title of navigationBar items for FileExporter because it is using System preferences as mentioned in offical document.

func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentType: UTType, onCompletion: (Result<[URL], Error>) -> Void) -> some View

Presents a system interface for allowing the user to export a collection of in-memory documents to files on disk.

Upvotes: 3

Related Questions