I added a PasteButton to my SwiftUI app, however it nonetheless reveals the “Enable Paste” immediate when tapped. After preventing this drawback for half a day with out success, I created a brand new SwiftUI app in Xcode and added this code from PasteButton documentation:
@State non-public var pastedText: String = ""
var physique: some View {
HStack {
PasteButton(payloadType: String.self) { strings in
pastedText = strings[0]
}
Divider()
Textual content(pastedText)
Spacer()
}
}
This works as anticipated within the Simulator: after I copy textual content, the button appears to be like enabled and there’s no immediate after I faucet it – the textual content is pasted immediately. Once I copy one thing else, say a picture, the button appears to be like disabled.
Once I run this pattern app on a tool and duplicate textual content, the button nonetheless appears to be like disabled. Once I faucet it, the immediate “Enable Paste” seems. If I faucet “Enable”, the textual content is pasted. What am I doing fallacious?