标签:iba nbsp webview bar forward adr str control error
// 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
标签:iba nbsp webview bar forward adr str control error
原文地址:http://www.cnblogs.com/laugh/p/6612489.html