how to show image in table cell through json parsing

前端 未结 4 1499
没有蜡笔的小新
没有蜡笔的小新 2021-01-26 14:51
NSURL *url = [NSURL URLWithString:@\"yourimage\"];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *img = [[[UIImage alloc] initWithData:data] autorelease];
<         


        
4条回答
  •  广开言路
    2021-01-26 15:16

    You can do it with

    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
    [[cell imageView] setImage:img];
    

    But thats probably not going to run very well because you're downloading the images synchronously and that will most likely make your app stutter.

    You should use lazy loading for the images, for an example take a look at http://developer.apple.com/library/ios/#samplecode/LazyTableImages/Introduction/Intro.html

提交回复
热议问题