1

クラスを使用して遅延読み込みを正常に実装しましたUIImageView+WebCache.h。クラスを使用せずに遅延読み込みを行う簡単な方法はありますUIImageView+WebCache.hか?

4

1 に答える 1

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;
    }
于 2012-08-18T22:06:28.963 に答える