开发者

WebView load css from local file

开发者 https://www.devze.com 2022-12-23 23:34 出处:网络
[[self mainFrame] loadHTMLString:@\"<html><body><link href=\'main.css\' rel=\'stylesheet开发者_运维知识库\' type=\'text/css\' /></body></html>\" baseURL:nil];
[[self mainFrame] loadHTMLString:@"<html><body><link href='main.css' rel='stylesheet开发者_运维知识库' type='text/css' /></body></html>" baseURL:nil];

I am trying to load a css file called main.css from the application Resources folder as below from a WebView, how do i get the path of the resources folder correct so i can load the css?


Just take a look at the NSBundle class:
http://developer.apple.com/mac/library/documentation/cocoa/reference/foundation/Classes/NSBundle_Class/Reference/Reference.html

[ [ NSBundle mainBundle ] pathForResource: @"file" ofType: @"css" ]

sorry for the bad formatting... Replied from my iPhone...

0

精彩评论

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