tags:

views:

22

answers:

2

HI all,

Is there any way by which we can edit a html file that is in our resource directory and we want to edit some tags in that html first and want to show that html in web view.

Is it possible ??

Thanks ...

A: 

Yes,

1) Locate and load the file

2) Make your edits

3) Save the file

You'll have to refresh the webview though for the changes to take effect.

Mr-sk
+1  A: 
NSBundle *bundle = [NSBundle bundleForClass:[self Class]];
NSString *htmlPath = [bundle pathForResource:@"html file name" ofType:@"htm"];
NSString *htmlContent = [NSString stringWithContentOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];

// Do your HTML edits here

[[self webView] loadHTMLString:htmlContent baseURL:nil];

This assumes that you've got a webview property of your view controller. Also, I don't know what the baseURL should be for local files. I know I've done this before, but I don't have access to those files right now. Hopefully this gets you part of the way there.

kubi