2011-03-24 34 views
0

在我viewControllerOne ,,,我使用tableview..and當我點擊任何row..I現在用這個code..to導航到另一個頁面......此代碼顯示文本而不是圖片所需的更改是什麼?

  Feches *rOVc = [[Feches alloc] initWithNibName:@"Feches" bundle:nil];  
      rOVc.hidesBottomBarWhenPushed = YES; 
      rOVc.title = [NSString stringWithFormat:@"15 March 2011"]; 
      rOVc.strURL = [[NSString alloc] initWithString:[[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"first_screen" ofType:@"png"]] absoluteString]]; 
      [self.navigationController pushViewController:rOVc animated:YES]; 
      [rOVc release]; 

現在,當它定位到Feches ...

在其獲取的viewDidLoad我使用此代碼...

NSString *html = [NSString stringWithFormat:@"<html><head>\ 
        <meta id='viewport' name='viewport' content='minimum-scale=0.2; maximum-scale=5; user-scalable=1;' />\ 
        </head><body style=\"margin:0\"><img id=\"yt\" src=\"%@\"></body></html>", self.strURL]; 

NSLog(@"html:%@",html); 
// Load the html into the webview 
if(self.myWeb == nil) { 
    self.myWeb = [[UIWebView alloc] initWithFrame:self.view.frame]; 
    [self.view addSubview:self.myWeb]; 
} 
[self.myWeb loadHTMLString:html baseURL:[NSURL URLWithString:self.strURL]]; 

這是顯示我的名字命名的圖片first_screen這是有以米y images images folder ...

現在...我想使用文本段落而不是圖片...但是使用相同種類的html和所有這些...任何人都可以請建議我,我必須做些什麼改變現在用於顯示段落而不是圖像?

回答

1

更改您的html字符串內容。將<img id=...>替換爲<p>text</p>

你在泄漏UIWebView(如果self.myWeb保留)。將您的代碼更改爲:

self.myWeb = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease]; 
self.myWeb = [[[UIWebView alloc] initWithFrame:self.view.frame] autorelease]; 
+0

..好吧,如果我想在此Web視圖中顯示「blah blah blah」這樣的文本,我應該更改哪些內容...? – 2011-03-24 13:29:15

+0

正如我寫的,用P標籤替換IMG標籤,並將這兩個P標籤之間的文本。 – robertvojta 2011-03-24 13:33:02

相關問題