IOS UIWebView学习
发布日期:2021-11-21 04:40:53 浏览次数:24 分类:技术文章

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

1.第一个列子,调用webview可以识别的字符串,当然该字符需要符合html格式规范

CGRect rect = self.view.bounds;        rect.origin.y +=20;        self.myWebView = [[UIWebView alloc]initWithFrame:rect];            [self.view addSubview:self.myWebView];                NSString *htmlString = @"IOS is runing OK!!!!";        [self.myWebView loadHTMLString:htmlString baseURL:Nil];
2.UIWebView调用远程的链接

CGRect rect = self.view.bounds;        rect.origin.y +=20;        self.myWebView = [[UIWebView alloc]initWithFrame:rect];            [self.view addSubview:self.myWebView];                NSString *htmlString = @"IOS is runing OK!!!!";        [self.myWebView loadHTMLString:htmlString baseURL:Nil];

3.UIWebViewDelegate的应用主要标明状态栏的内容

#import "IKEDViewController.h"@interface IKEDViewController ()
@end@implementation IKEDViewController- (void)viewDidLoad{ [super viewDidLoad]; CGRect rect = self.view.bounds; rect.origin.y +=20; self.myWebView = [[UIWebView alloc]initWithFrame:rect]; self.myWebView.scalesPageToFit = YES; [self.view addSubview:self.myWebView]; NSURL *url = [NSURL URLWithString:@"http://www.hao123.com"]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; self.myWebView.delegate = self; [self.myWebView loadRequest:request];}-(void)webViewDidStartLoad:(UIWebView *)webView{ [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:YES];}-(void)webViewDidFinishLoad:(UIWebView *)webView{ [[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];}-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error{[[UIApplication sharedApplication]setNetworkActivityIndicatorVisible:NO];}- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning];}

(PS:原创文章,转载请标明出处)

转载地址:https://blog.csdn.net/xiaoji94shen/article/details/19493983 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:IOS 并发处理
下一篇:IOS UIScrollView学习

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月21日 03时26分05秒