【问题标题】:use UIWebview in a TableView Cell?在 TableView 单元格中使用 UIWebview?
【发布时间】: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


    【解决方案1】:

    确保在委托方法的末尾有return cell;

    【讨论】:

    • webview 正在显示,但是图片没有加载??
    • 看起来他没有粘贴整个方法
    猜你喜欢
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2017-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多