[英]How to display different images on tableview at a time by doing JSON Pasing in iOS?
I have one API.It is having 4 images and 4 descriptions and 4 names. 我有一个API,它有4个图像,4个描述和4个名称。 So My question is when we parse and run the app these things should be displayed at a time. 所以我的问题是,当我们解析并运行应用程序时,这些内容应该一次显示。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
DetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (indexPath.section==0)
{
cell.discriptionLabel.text = [arrDiscription objectAtIndex:indexPath.row];
}
else if (indexPath.section==1)
{
cell.displayLabel.text = [arrDisplayName objectAtIndex:indexPath.row];
}
else
{
[cell.imgObj setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"image"]]]];
}
return cell;
}
NSArray *arrActivity1=[dictionray valueForKey:@"products"];
for (NSDictionary *dicObj in arrActivity1)
{
NSString *strDiscription=[dicObj valueForKey:@"description"];
[arrDiscription addObject:strDiscription];
NSLog(@"discriptions are %@",arrDiscription);
NSString *strDisplyName=[dicObj valueForKey:@"display_name"];
[arrDisplayName addObject:strDisplyName];
NSLog(@"displaynames are %@",arrDisplayName);
}
This is my parsing, but I am unable to display the images on the tableview. 这是我的解析,但是无法在tableview上显示图像。 Please anyone help me. 请任何人帮助我。
Is what you're looking for. 就是您要的东西。
Use it in your cellForRowAtIndexPath
delegate method like this: 在您的cellForRowAtIndexPath
委托方法中使用它,如下所示:
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:@"image"] placeholderImage:[UIImage imageNamed:@"sampleimage.png"]];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.