iOS加载本地html,可以使用控件来实现。创建一个控件:
iOS加载本地html,可以使用UIWebView控件来实现。
首先,创建一个UIWebView控件:
objective-c
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:webView];
然后,获取本地html文件的路径:
objective-c
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
最后,使用UIWebView加载html文件:
objective-c
NSURL *url = [NSURL fileURLWithPath:filePath];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处
评论列表(12条)