英文:
How to customize swiftui file exporter to show save instead of move
问题
我想允许用户导出一个文本文件并将其保存到他们的文件系统中。然而,SwiftUI 在弹出视图中显示一个按钮,上面写着“移动”,而不是“保存”。我该如何更改这种行为?
英文:
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)
}
} }
}
答案1
得分: 1
iOS 不允许我们更改 FileExporter 的导航栏项目标题,因为它使用了官方文档中提到的系统偏好设置。
func fileExporter<C>(isPresented: Binding<Bool>, documents: C, contentType: UTType, onCompletion: (Result<[URL], Error>) -> Void) -> some View
提供了一个用于允许用户将一组内存中的文档导出到磁盘文件的系统界面。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论