UIWebView加载本地页面和远程页面

一、加载本地页面

NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"index2" 
														  ofType:@"html"];
	NSData *data = [NSData dataWithContentsOfFile: htmlPath];
 	NSString *info = [[NSString alloc] initWithData:data
										   encoding:NSUTF8StringEncoding];
	[self.MyWebView loadHTMLString:info
						   baseURL:[NSURL fileURLWithPath: htmlPath]];

 二、加载远程页面

NSString *urlString=[ NSString stringWithFormat : @"%@" , @"http://192.168.1.129:8080/NRPTProject/jsp/index/index.jsp" ];
	NSURL *url=[ NSURL URLWithString :urlString];
	NSURLRequest *request=[ NSURLRequest requestWithURL :url];
	[self.MyWebView loadRequest :request];
 

你可能感兴趣的:(UIWebView)