Load image to a tableView from URL iphone sdk

前端 未结 6 1457
攒了一身酷
攒了一身酷 2020-12-02 17:53

I have tableView and need to load image from URL. I have an array that contains the URLs of images and when the page loads I need to load all the images into the tableview.

6条回答
  •  庸人自扰
    2020-12-02 18:25

    Try this code,imagearray contains urls of image

    -(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString: [imagearray objectAtIndex:row]]];
        UIImage* image = [[UIImage alloc] initWithData:imageData];
    
    
        cell.imageView.image =image;
        return cell;
    }
    

提交回复
热议问题