I am attempting to have a UIBarButton
(right side) as a paste button. The user will have already copied text to the UIPasteBoard
in the previous ViewController
. When hitting the UIBarButton
(Paste), The text should appear on the text field on the website that the user is focused on. For example, if the user taps the Google search box
, then presses Paste, the text should appear.
I have only found solutions to use UIPasteBoard
with strings to paste into UITextFields
, UITextViews
within the app and not into WKWebViews
.
@IBOutlet var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Paste", style: .plain, target: self, action: #selector(pasteText))
let myURL = URL(string:"https://www.google.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
@objc func pasteText() {
// Code?
}
Trying to use UIPasteBoard
to paste text into a textfield in a website (WKWebView
).