trouble loading html file from plist to webView using following code in
FAQDetailViewController.m: - (void)viewDidLoad { [super viewDidLoad]; NSString *Pa开发者_Python百科th = [[NSBundle mainBundle] bundlePath]; NSString *WebPath = [Path stringByAppendingPathComponent:WebFile]; UIWebView *tempWeb = [[UIWebView alloc] initWithContentsOfFile:WebPath]; [webView loadData:tempWeb]; //I think my issue is here. I am not understanding how to implement the the code here [tempWeb release]; }
loaded here with this peace of code in FAQViewController.m:
FAQDetailViewController *faqdvController = [[FAQDetailViewController alloc] initWithNibName:@"FAQDetailView" bundle:[NSBundle mainBundle]]; faqdvController.WebFile = [dictionary objectForKey:@"faqDesc"]; //html file from plist file placed here faqdvController.hidesBottomBarWhenPushed = NO; [self.navigationController pushViewController:faqdvController animated:YES]; [faqdvController release];
You can try it this way:
NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *webPath = [bundle stringByAppendingPathComponent:{htmlFilename}]
UIWebView* browser = [[UIWebView alloc] initWithFrame:
CGRectMake(0, 0, 200, 300)];
[browser loadRequest:[NSURLRequest requestWithURL:
[NSURL fileURLWithPath:webPath]]];
[self addSubview:browser];
You'll also want to set delegates on the browser so you get informed when the contents have finished loading.
精彩评论