Hi everyone,
I've implemented a UIPasteControl in my iOS app using the following code:
func displayPasteControl() {
if #available(iOS 16.0, *) {
let pasteControlConfig = UIPasteControl.Configuration()
let newPasteControlButton = UIPasteControl(configuration: pasteControlConfig)
self.inputContainerView.addSubview(newPasteControlButton)
newPasteControlButton.isEnabled = true
// Set constraints for this button
newPasteControlButton.translatesAutoresizingMaskIntoConstraints = false
newPasteControlButton.topAnchor.constraint(equalTo: self.originalPasteView.topAnchor, constant: 0).isActive = true
newPasteControlButton.centerXAnchor.constraint(equalTo: self.inputContainerView.centerXAnchor).isActive = true
newPasteControlButton.widthAnchor.constraint(equalTo: self.originalPasteView.widthAnchor, multiplier: 0.5).isActive = true
newPasteControlButton.bottomAnchor.constraint(equalTo: self.originalPasteView.bottomAnchor, constant: 0).isActive = true
newPasteControlButton.target = self.inputTextView
}
}
I call this function in viewWillAppear:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
displayPasteControl()
}
Sometimes, I've noticed that the UIPasteControl button appears in a disabled state visually, but when I press it, the content from the clipboard is still pasted. I checked the state of UIPasteControl and it indicates that it is in an enabled state. For context, the UIPasteControl target is set to a UITextView (self.inputTextView).
Has anyone experienced this issue or have any idea why this might be happening? Any help would be appreciated!
Thank you!