开发者

run locally created file on iPhone safari

开发者 https://www.devze.com 2023-02-13 14:20 出处:网络
am new to iOS application dev. I want to ask whether could create a html file and save it in app (files) and run this html file on iOS saf开发者_Python百科ari?

am new to iOS application dev. I want to ask whether could create a html file and save it in app (files) and run this html file on iOS saf开发者_Python百科ari?

thanks al


I don't think it is possible. Neither UIApplication's openURL: nor UIDocumentInteractionController will open an html file in Safari. I would suggest you instantiate your own "Safari" (UIWebView) and open the html file within your app. If will behave pretty much like Safari.


You can't, unless you jailbreak in which case you can start a local web server on the iPhone.


Use UIWebView to load html file. visit webView class Reference for detail documentation.

UIWebView *webView=[[UIWebView alloc ]initWithFrame:CGRectMake(0,0, 320, 480)];
[window/someotherview addSubView: webView];
NSURL *url=[NSURL fileURLWithPath:[[NSBundle mainBundle] @"index" ofType:@"html"]];
NSURLRequest *reqUrl=[NSURLRequest requestWithURL:url];
[webView loadRequest:reqUrl];

0

精彩评论

暂无评论...
验证码 换一张
取 消