【发布时间】:2019-04-22 20:46:04
【问题描述】:
self->SCImageArr = [[NSMutableArray alloc]init];
self->SCLabelArr = [[NSMutableArray alloc]init];
NSDictionary *SCDic = [maindic objectForKey:@"specialcategories"];
for (NSDictionary *SCDictionary in SCDic){
NSString *strimage = [SCDictionary objectForKey:@"image"];
[self->SCImageArr addObject:strimage];
NSLog(@"SCImage :%@", strimage);
NSString *strname = [SCDictionary objectForKey:@"text"];
[self->SCLabelArr addObject:strname];
NSLog(@"SClabelname :%@", strname);
}
[self.specialCategoriesCollectionView reloadData];
我的手机密码在这里
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIndentifer = @"Cell";
SpecialCategoriesCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIndentifer forIndexPath:indexPath];
cell.categoriesImages.image = [UIImage imageWithData:SCImageArr];
cell.categoriesNameLabel.text = self.specialCategoriesLabel[indexPath.row];
return cell;
}
如何使用objective c从json中获取collectionview单元格中的图像?
【问题讨论】:
-
请以小写字母开头命名您的变量。不要将多个数组用于同步的值。而是将字典解析为自定义类。还有
strimage是什么?那是网址吗?那是 Base64Image 数据吗?
标签: objective-c iphone uicollectionview uiimageview