码迷,mamicode.com
首页 > Web开发 > 详细

源码0604-12-掌握-webView

时间:2017-03-24 17:30:13      阅读:219      评论:0      收藏:0      [点我收藏+]

标签: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

 

源码0604-12-掌握-webView

标签:iba   nbsp   webview   bar   forward   adr   str   control   error   

原文地址:http://www.cnblogs.com/laugh/p/6612489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!