ios使用webview浏览指定网页

#import "EDRViewController.h"

@interface EDRViewController ()
@property(nonatomic,weak) UIWebView * webView;
@end

@implementation EDRViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIWebView * webView=[[UIWebView alloc] initWithFrame:self.view.bounds];
    
    webView.backgroundColor=[UIColor redColor];
    
    [self.view addSubview:webView];
    self.webView=webView;

    [self loadRemoteHTML];
	// Do any additional setup after loading the view, typically from a nib.
}

#pragma mark 加载远程的HTML页面
- (void)loadRemoteHTML {
    NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];
    [self.webView loadRequest:[NSURLRequest requestWithURL:url]];
}

 

原文地址:https://www.cnblogs.com/coolyylu/p/4923342.html