源码0604-12-掌握-webView
Posted laugh
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了源码0604-12-掌握-webView相关的知识,希望对你有一定的参考价值。
// ViewController.m // 12-掌握-webView #import "ViewController.h" @interface ViewController () <UIWebViewDelegate> @property (weak, nonatomic) IBOutlet UIWebView *webView; @property (weak, nonatomic) IBOutlet UIBarButtonItem *backItem; @property (weak, nonatomic) IBOutlet UIBarButtonItem *forward; @end @implementation ViewController - (IBAction)back:(id)sender { [self.webView goBack]; } - (IBAction)forward:(id)sender { [self.webView goForward]; } - (IBAction)refresh:(id)sender { [self.webView reload]; } - (void)viewDidLoad { [super viewDidLoad]; // Native(OC+Swift) + html5 self.webView.delegate = self; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]]]; } #pragma mark - <UIWebViewDelegate> - (void)webViewDidFinishLoad:(UIWebView *)webView { NSLog(@"%s", __func__); self.backItem.enabled = webView.canGoBack; self.forward.enabled = webView.canGoForward; } - (void)webViewDidStartLoad:(UIWebView *)webView { NSLog(@"%s", __func__); } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { NSLog(@"%s", __func__); self.backItem.enabled = webView.canGoBack; self.forward.enabled = webView.canGoForward; } @end
以上是关于源码0604-12-掌握-webView的主要内容,如果未能解决你的问题,请参考以下文章
我的片段中有 webview,当滑动 webview 时, viewPager 也开始滑动