I have HTML I am generating in my app. I know it's valid because I ran it through W3Schools "edit and try it". It performs exactly as I designed it.
Here is the definition of the website in the header file:
@interface ReportViewController : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *reportWebView;
}
@property (nonatomic, retain) UIWebView *reportWebView;
@property (nonatomic, retain) NSMutableString *html;
- (void) generateReport;
- (void) Alert: (NSString *) title andData: (NSString *) errorMsg;
@end
Here is where I finish creating the HTML and try to display it:
// now do the table
[html appendString:@"<div><table border class=\"boldtable\">"
"<tr BGCOLOR=\"ADDAFE\">"
"<th>STA </th><th>BS </th><th>HI </th><th>FS </th><th>ELEV </th><th>Desc</th>"
"</tr><p>"];
}
// finally, end the table, etc.
[html appendString:@"</table></div></body></html>"];
// UIWebView *reportWebView = [[UIWebView alloc] init];
//[reportWebView loadHTMLString: html baseURL:nil];
[self.reportWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
}
As you can see, I have tried several different variations of displaying the HTML string. What is the correct way to do this?
Iulius Caesar Jacques Cousteau gave the correct answer in a comment :
reportWebView
is anIBOutlet
, indicating that it's created in an xib. Is the outlet connected? Is the nib loaded? What's with the commented-outUIWebView *reportWebView = [[UIWebView alloc] init];
? Is this your exact code? Are you creating a local variablereportWebView
that's shadowing the ivar?
but never came back to set it, therefore I am answering it for him.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.