[英]use UIWebview in a TableView Cell?
我正在嘗試使用以下方法在tableView單元中的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;
}
但沒有圖像加載到Webview中。 如何在Webview中顯示圖像?
確保return cell;
在委托方法的末尾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.