2012-04-18 43 views
0

我有我在我的应用程序中生成的HTML。我知道这是有效的,因为我通过W3Schools“编辑并尝试它”来运行它。它完全按照我的设计执行。为什么这个动态生成的HTML不会显示在UIWebView中?

这里是在头文件的网站的定义:

@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 

这里是我完成创建HTML,并尝试以显示它:

 // now do the table 
     [html appendString:@"<div><table border class=\"boldtable\">" 
     "<tr BGCOLOR=\"ADDAFE\">" 
     "<th>STA&nbsp;</th><th>BS&nbsp;</th><th>HI&nbsp;</th><th>FS&nbsp;</th><th>ELEV&nbsp;</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]]]; 
} 

正如你所看到的,我已经尝试了几种不同的显示HTML字符串的变体。什么是正确的方法来做到这一点?

+0

你在哪里追加字符串?是否过了关闭标签也许? – Lefteris 2012-04-18 20:01:54

+0

不,最终的HTML字符串是有效的,正如我最初提到的。我相信这与我试图在UIWebView中显示它的方式有关。我之前使用文本文件完成了此操作,但从未使用动态生成的HTML。 – SpokaneDude 2012-04-18 20:09:27

+0

为什么不尝试用JavaScript插入它?您可以使用adjacentHTML dom方法来插入html ... – Lefteris 2012-04-18 20:12:23

回答

0

尤利乌斯凯撒雅克·库斯托给出了正确的答案in a comment

reportWebViewIBOutlet,表明它是在厦门国际银行创建的。插座是否连接?笔尖是否加载?什么是注释掉UIWebView *reportWebView = [[UIWebView alloc] init];?这是你的确切代码吗?你是否创建了一个局部变量reportWebView这是阴影伊娃?

但从来没有回来设置它,因此我正在为他回答。

+0

直到现在我还没有看到您的回复(清理旧评论),因为您在评论中没有使用“@ @ @ @ Iulius”。没问题,但。你可能应该在这个答案中更清楚地表达我的意见,因为我提出了几点意见。 – 2012-04-27 07:01:17

相关问题