Loading images from a URL into a UITableViewCell's UIImageView

前端 未结 4 2181
面向向阳花
面向向阳花 2020-12-14 13:26

I have the following code: (Note: newsImageURL is an NSArray)

NSString *imagesURL = @\"http://aud.edu/images/newsimage01.png,http:/         


        
4条回答
  •  余生分开走
    2020-12-14 14:07

    You can load data this way:

    NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString: [newsImageURL objectAtIndex:indexPath.row]]];
    

    And you can instantiate the array of URLs this way too:

    NSArray *newsImageURL = [imagesURL componentsSeparatedByString:@","];
    

    However, if someone scrolls around on the table a great deal, you may end up loading the images many times over as the cells are recycled.

提交回复
热议问题