Philip Pegden
Philip Pegden

Reputation: 2134

Why is the FileExporter move button disabled on iOS16.1

When this code is run, the dialog box appears, but the Move button is disabled.

Has anyone else run across this problem on Xcode 14.1 beta 3 / iOS16.1 on the iPad simulator? Is there an obvious mistake? If not I'll raise a Feedback report with Apple.

enter image description here

import SwiftUI
import UniformTypeIdentifiers

struct ContentView: View {
    @State private var showFileExporter: Bool = false
    
    var body: some View {
        VStack {
            Text("Export file")
                .onTapGesture {
                    showFileExporter = true
                }
                .fileExporter(isPresented: $showFileExporter, document: TextFile(), contentType: UTType.text) { result in }
        }
        .padding()
    }
}

struct TextFile: FileDocument {
    static var readableContentTypes = [UTType.text]
    static var writableContentTypes = [UTType.text]
    
    var text = ""
    
    init() {}

    init(configuration: ReadConfiguration) throws {
        if let data = configuration.file.regularFileContents {
            text = String(decoding: data, as: UTF8.self)
        }
    }
    
    func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
        let data = Data(text.utf8)
        return FileWrapper(regularFileWithContents: data)
    }
}

Upvotes: 1

Views: 213

Answers (1)

spfursich
spfursich

Reputation: 5405

I just updated to beta 5 and the problem has been resolved. The button can be pressed again :)

Upvotes: 1

Related Questions