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.
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)
}
} }
}
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.