[英]how to insert json image data in to uitableview ios(obj -C)
hear is the response and please do explain in detail Thanks in advance 听到是回应,请做详细解释预先感谢
{
"success": "true",
"data": {
"per_page": 25,
"total_records": "12",
"products": [
{
"product_id": "48",
"price": "1699.0000",
"image": "data/newimages/1.jpg",
"status": "1",
"description": "nill",
"name": "Buy 2 Denim Jeans & 1 Round Tee & 1 Casual Shirt get one Casual Watch free"
},
{
"product_id": "47",
"price": "2500.0000",
"image": "data/newimages/2.jpg",
"status": "1",
"description": "nill",
"name": "2 Branded denim Jeans & 2 Casual Shirt + 1 round neck tee and get a Watch , Card Holder free"
},
{
"product_id": "43",
"price": "1999.0000",
"image": "data/newimages/12.jpg",
"status": "1",
"description": "nill",
"name": "Complete Formal Combo By 2 cotton formal trousers & 2 Formal Shirts + 1 formal shoe & 2 formal Belts"
},
{
"product_id": "40",
"price": "1599.0000",
"image": "data/newimages/8.jpg",
"status": "1",
"description": "nill",
"name": "7 printed super hero & disney Round Neck Tees get 1 Sneaker Shoes free"
},
{
"product_id": "39",
"price": "2000.0000",
"image": "data/newimages/18.jpg",
"status": "1",
"description": "nill"
"name": "Its time to steel the looks with these 5 100% cotton formal Shirts"
}
]
}
You can easily do this by downloading SDWebImage library, after downloading sdwebimage you need to first import it 您可以通过下载SDWebImage库轻松完成此操作,在下载sdwebimage之后,您需要先将其导入
#import "UIImageView+WebCache.h"
After import check my "cellForRowAtIndexPath" method of UITableView 导入后,检查我的UITableView的“ cellForRowAtIndexPath”方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
[cell.ImageView sd_setImageWithURL:[NSURL URLWithString:@“URL String”] placeholderImage:[UIImage imageNamed:@“Place holder image name“]];
return cell;}
You can get the array using the below code 您可以使用以下代码获取数组
NSDictionary *dictionaryYouAlreadyHave;
NSArray *productArray = [[[dictionaryYouAlreadyHave objectForKey:@"data"] objectForKey:@"products"]];
And you can get image name using below code 您可以使用以下代码获取图像名称
NSDictionary *dict = [productArray objectAtIndex:0];
NSString *imgName = [dict objectForKey:@"image"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.