Reputation: 185
i am new to ios so excuse me if i write something wrong First as appear in .m file i read file and append some code its work fine and display data as expected except in one ,
it convert html tags to (& lt ;) but without space
this make my web view why that happen
.h file
@interface FullReport : UIViewController<UIWebViewDelegate >
@property (weak, nonatomic) IBOutlet UIWebView *web;
.m file
- (void)viewDidLoad
{
//read FilePath
NSString * myPath= [[NSBundle mainBundle] pathForResource:@"content" ofType:@"txt"];
// read file content html code
NSString *fileContent = [[NSString alloc]initWithContentsOfFile:myPath encoding:NSUTF8StringEncoding error:nil];
// append some code to it
fileContent = [fileContent stringByAppendingString:reportBody];
NSLog(@"content file %@",fileContent);
// laod it into my UIWebView
[web loadHTMLString:fileContent baseURL:[NSURL fileURLWithPath:myPath]];
[super viewDidLoad];
}
Upvotes: 0
Views: 386
Reputation: 811
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:<filepath>]]];
here filepath is the path of the file content stored.
Upvotes: 1