博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iPhone控件之UIWebView2
阅读量:5260 次
发布时间:2019-06-14

本文共 1813 字,大约阅读时间需要 6 分钟。

1 #import 
2 3 @interface UITestViewController : UIViewController
4 {
5 6 } 7 8 @end 9 10 11 // 12 // UITestViewController.m 13 // UITest 14 // 15 16 #import "UITestViewController.h" 17 18 @implementation UITestViewController 19 20 - (void)viewDidLoad {
21 22 [super viewDidLoad]; 23 24 CGRect webRect = CGRectMake(10,10,300,400); 25 UIWebView *myWebView = [[UIWebView alloc] initWithFrame:webRect]; 26 27 myWebView.delegate = self; 28 29 myWebView.scalesPageToFit = NO; 30 NSString *htmlPath = [[NSBundle mainBundle] pathForResource:@"myPage" ofType:@"html"]; 31 NSString *htmlContent = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil]; 32 33 [myWebView loadHTMLString:htmlContent baseURL:nil]; 34 35 [self.view addSubview:myWebView]; 36 37 [myWebView release]; 38 } 39 40 - (BOOL)webView:(UIWebView *)webView 41 shouldStartLoadWithRequest:(NSURLRequest *)request 42 navigationType:(UIWebViewNavigationType)navigationType {
43 NSURL *pageURL = [request URL]; 44 45 if ( ([[pageURL scheme] isEqualToString: @"http"]) && (navigationType == UIWebViewNavigationTypeLinkClicked )) 46 {
47 [[UIApplication sharedApplication] openURL:pageURL]; 48 return NO; 49 } 50 51 return YES; 52 } 53 54 55 - (void)didReceiveMemoryWarning {
56 // Releases the view if it doesn't have a superview. 57 [super didReceiveMemoryWarning]; 58 59 // Release any cached data, images, etc that aren't in use. 60 } 61 62 - (void)viewDidUnload {
63 // Release any retained subviews of the main view. 64 // e.g. self.myOutlet = nil; 65 } 66 67 68 - (void)dealloc {
69 70 [super dealloc]; 71 } 72 73 @end

转载于:https://www.cnblogs.com/foxmin/archive/2012/03/13/2393664.html

你可能感兴趣的文章
ASP.NET WebApi 基于OAuth2.0实现Token签名认证
查看>>
283. Move Zeroes把零放在最后面
查看>>
Visual Studio Code 打开.py代码报Linter pylint is not installed解决办法
查看>>
Python 数据类型
查看>>
S5PV210根文件系统的制作(一)
查看>>
centos下同时启动多个tomcat
查看>>
slab分配器
查看>>
数据清洗
查看>>
【读书笔记】C#高级编程 第三章 对象和类型
查看>>
针对sl的ICSharpCode.SharpZipLib,只保留zip,gzip的流压缩、解压缩功能
查看>>
【转】代码中特殊的注释技术——TODO、FIXME和XXX的用处
查看>>
【SVM】libsvm-python
查看>>
Jmeter接口压力测试,Java.net.BindException: Address already in use: connect
查看>>
Leetcode Balanced Binary Tree
查看>>
Leetcode 92. Reverse Linked List II
查看>>
九.python面向对象(双下方法内置方法)
查看>>
go:channel(未完)
查看>>
[JS]递归对象或数组
查看>>
LeetCode(17) - Letter Combinations of a Phone Number
查看>>
Linux查找命令对比(find、locate、whereis、which、type、grep)
查看>>