【发布时间】:2010-07-12 07:24:06
【问题描述】:
我正在尝试使用 uiwebview 在 tableView 单元格中加载图像
- (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;
}
但没有图像被加载到 web 视图中。如何在 webview 中显示图像?
【问题讨论】:
标签: iphone iphone-sdk-3.0