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 = @"xixi";
    
    myWebView.frame = self.view.bounds;
    
    myWebView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    
    myWebView.dataDetectorTypes = UIDataDetectorTypeAll;
    
    NSString *html = @"<br/><br/><br/><b>[手机号码]</b>"
    "000-00000-0000<hr/>"
    "<b>[主页]</b><br/>"
    "http://www.baidu.com/";
    
    [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