容易延迟加载

时间:2012-08-18 22:01:15

标签: iphone objective-c ios uitableview uiimageview

我已使用类UIImageView+WebCache.h成功实现了延迟加载。 是否有任何简单的延迟加载方法而不使用类UIImageView+WebCache.h

1 个答案:

答案 0 :(得分:1)

您可以在UIWebView中加载图像。例如:

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

    static NSString *identifier = @"ID";

    UITableViewCell *cell = [self.tv dequeueReusableCellWithIdentifier:identifier];

        if(cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];

            UIWebView *webView=[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];

            NSLog(@"URL=%@",[arrayURL objectAtIndex:indexPath.row]);

            NSURL *url=[NSURL URLWithString:[arrayURL objectAtIndex:indexPath.row]];
            NSURLRequest *req=[NSURLRequest requestWithURL:url];
            [webView loadRequest:req];
            webView.scalesPageToFit=TRUE;
            [cell.contentView addSubview:webView];

        }
        return cell;
    }
相关问题