2010-07-12 68 views
0

我試圖用在TableView Cell中使用UIWebview?

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 
} 

NSInteger Index=indexPath.row; 
switch (Index) 
{ 

case 0: 

[cell.contentView addSubview:webView]; 

     NSString *str=[[NSString alloc]initWithFormat:@"%@",[appDelegate.respSrcUrl objectAtIndex:0]]; 

     NSURL *url = [NSURL URLWithString: str]; 

     NSString *htmlString = @"<html><body><img src='%@' width='900'></body></html>"; 
     NSString *imageHTML = [[NSString alloc] initWithFormat:htmlString,url]; 


     webView.scalesPageToFit = YES; 

     [webView loadHTMLString:imageHTML baseURL:nil]; 


break; 

default: 

break; 
} 

加載在UIWebView的一個圖像中的tableView細胞,但沒有像在WebView中得到加載。我怎麼能在webview中顯示圖像?

回答

0

確保您在代表方法的末尾有return cell;

+0

webview顯示,但圖像在不加載?? ?? – hemant 2010-07-12 08:26:41

+0

看起來他沒有粘貼整個方法 – willcodejavaforfood 2010-07-12 08:39:12