adolsai's echo

Objective-C Learning Notes - UIWebView3

加载 html 代码:

通过使用 UIWebView 的 loadHTMLString:baseURL 方法加载显示如下 HTML 代码:

"<br/><br/><br/><b>[手机号码]</b>"
    "000-00000-0000<hr/>"
    "<b>[主页]</b><br/>"
    "http://www.baidu.com/";


#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize myWebView;
- (void)viewDidLoad {
    [super viewDidLoad];
self.title = @&quot;xixi&quot;;

myWebView.frame = self.view.bounds;

myWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;

myWebView.dataDetectorTypes = UIDataDetectorTypeAll;

NSString *html = @&quot;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;b&gt;[手机号码]&lt;/b&gt;&quot;
&quot;000-00000-0000&lt;hr/&gt;&quot;
&quot;&lt;b&gt;[主页]&lt;/b&gt;&lt;br/&gt;&quot;
&quot;http://www.baidu.com/&quot;;

[myWebView loadHTMLString:html baseURL:nil];

[self.view addSubview:myWebView];

// Do any additional setup after loading the view, typically from a nib.

}

  • (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end

屏幕快照 2015-02-19 下午7.51.09.png

标签:#ios #object-c #uiwebview