我目前创建了一个webview,但我不想使用界面构建器来创建后退,前进和刷新按钮.如何以编程方式创建这些按钮?我知道如何使用代码创建常规按钮,但对于webView委托按钮,我迷路了,并且无法在其上找到许多资源.
解决方法
从
UIWebView文档:
If you allow the user to move back and forward through the webpage history,then you can use the 07001 and 07002 methods as actions for buttons. Use the 07003 and 07004 properties to disable the buttons when the user can’t move in a direction.
然后设置按钮将使用addTarget:action:forControlEvents:
(如Sven所指出):
[myBackButton addTarget:myWebView action:@selector(goBack) forControlEvents:UIControlEventTouchDown];
如果您希望根据canGoBack和canGoForward属性获得想象并启用/禁用按钮,则必须向UIController添加一些KVO通知.