开发者

How to stop UIWebView from caching CSS?

开发者 https://www.devze.com 2023-01-30 07:53 出处:网络
I have an app which has in bundle a css file and more html files. When the user taps a button I change the css file and call [webView reload]开发者_JAVA技巧 but nothing happens. I think this is becaus

I have an app which has in bundle a css file and more html files. When the user taps a button I change the css file and call [webView reload]开发者_JAVA技巧 but nothing happens. I think this is because the webview caches the old css file and reloads the page using that one.

How can I prevent this?

I tried using the info found here but I don't really understand what the technique is about.

Do I have to change the style.css somehow? Do I have to add the version variable to it?

because If I only use this line of code:

[htmlString stringByReplacingOccurrencesOfString:@"style.css" withString:[NSString stringWithFormat:@"style.css?time=%@", [[NSDate date] description]]

my app crashes.

Any pointers of how to solve this problem would be great. Thank you!


Are you using the same filename for both CSS files? If you think that the UIWebView is caching one of them, then just name the other something different.

0

精彩评论

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