您的位置:首页 > 移动开发

Loads the local HTML file into the web view in the app

2013-02-28 00:22 405 查看
- (void)viewDidLoad
{

[super
viewDidLoad];

// Do any additional setup after loading the view from its nib.

NSString *htmlFile = [[NSBundle
mainBundle] pathForResource:@"BullsEye"
ofType:@"html"];

NSData *htmlData = [NSData
dataWithContentsOfFile:htmlFile];

NSURL *baseURL = [NSURL
fileURLWithPath:[[NSBundle
mainBundle] bundlePath]];

[self.webView
loadData:htmlData MIMEType:@"text/html"
textEncodingName:@"UTF-8"
baseURL:baseURL];
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"BullsEye" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:htmlFile];
NSURL  *baseURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]];
[self.webView loadData:htmlData MIMEType:@"text/html" textEncodingName:@"UTF-8" baseURL:baseURL];
}


1. We find the BullsEye.html file in our application bundle,then we load it into an NSData object, and finally we ask the web view to show the contents of this data object.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐