Meet Transferable

RSS for tag

Discuss the WWDC22 Session Meet Transferable

Posts under wwdc2022-10062 tag

2 Posts
Sort by:
Post not yet marked as solved
1 Replies
859 Views
It seems that the modifier func suggestedFileName(_ fileName: String) -> some TransferRepresentation can only set the filename for the entire Transferable type. What I want is to set the filename for each instance. Every instance of a Transferable type shouldn't have the same filename. static var transferRepresentation: some TransferRepresentation { FileRepresentation(exportedContentType: .myType) { myTransferable in         let url = try await myTransferable.exportedFileUrl()         return SentTransferredFile(url) /* maybe set the specific filename on SentTransferredFile? */     } .suggestedFileName("Unnamed") // maybe this should be a fallback filename }
Posted
by szquest.
Last updated
.
Post not yet marked as solved
7 Replies
1.9k Views
I've discovered an issue with using iOS 16's Transferable drag-and-drop APIs for SwiftUI. The dropDestination modifier does not work when applied to a subview of a List. This code below will not work, unless you replace the List with a VStack or any other container (which, of course, removes all list-specific rendering). The draggable modifier will still work and the item will drag, but the dropDestination view won't react to it and neither closure will be called. struct MyView: View { var body: some View { List { Section { Text("drag this title") .font(.largeTitle) .draggable("a title") } Section { Color.pink .frame(width: 400, height: 400) .dropDestination(for: String.self) { receivedTitles, location in true } isTargeted: { print($0) } } } } } Has anyone encountered this bug and perhaps found a workaround?
Posted Last updated
.