OC UIWebView 用法

来源:互联网 发布:英语背诵材料推荐知乎 编辑:程序博客网 时间:2024/04/29 10:55

一、加载服务器页面

CGRect ScreenWhWithCGRect = [UIScreen mainScreen].bounds;  //结构体 获取xy with height


UIURL *url = [UIURL URLWithString:@"http://www.baidu.com"];


NSURLRequest *request = [NSURLRequest requestWithURL:url];


UIWebView *webView = [[UIWebView alloc] initWithFrame:ScreenWhWithCGRect] ;


[self.view addSubview:webView ];


二、HTML 转换 为 UIWebView中

CGRect ScreenWhWithCGRect = [UIScreen mainScreen].bounds;  //结构体 获取xy with height


NSString *htmlCode = @“<div style=\"text-align:center;\"><h1>Hello iOS </h1></div>”;


UIWebView *webView = [[UIWebView alloc] initWithFrame:ScreenWhWithCGRect] ;


[webView loadHTMLString:htmlCode  baseUrl:nil];


[self.view addSubview:webView ];


三、调用本地safari浏览器打开网址

NSURL *url = [NSURL URLWithString:@"http://www.baidu.com"];

[[UIApplication sharedApplication] openURL: url];


其他UIWebView使用方法陆续更新中。。。。 今天有点困了(以上手敲代码 如有错误请留言,及时更正)

0 0