I currently have a webview created but I do not want to use interface builder to create the back, forward, and refresh buttons. How would I create these buttons programmatically? I know how to create regular buttons with code, but as for webView delegate buttons, I am lost and have not been able to find many resources on it.
From the UIWebView documentation:
If you allow the user to move back and forward through the webpage history, then you can use the goBack and goForward methods as actions for buttons. Use the canGoBack and canGoForward properties to disable the buttons when the user can’t move in a direction.
Setting up the buttons would then use addTarget:action:forControlEvents:
(as pointed out by Sven):
[myBackButton addTarget:myWebView
action:@selector(goBack)
forControlEvents:UIControlEventTouchDown];
If you want to get fancy and enable/disable the buttons based on the canGoBack
and canGoForward
properties, you will have to add some KVO notifications to your UIController
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With