Ich erstelle eine UIImageview und zwei UILables in UICollectionviewcell.my Daten in NSArray und Format gespeichert ist NSDictionary, Schlüssel und Werte. aber Daten wurden nicht in UICollectionviewCell angezeigt. Dies ist mein Code Bitte überprüfen Sie meinen Code.Daten nicht in UICollectionviewcell angezeigt?
//---- ItemviewController ---//
mensarrayimages = @[ @{ @"description": @"Mens Fashion",
@"articles": @[ @{ @"image": @"SlimFit.jpg" },
@{ @"image": @"Brown.jpg" },
@{ @"image": @"Black.jpg" },
@{ @"image": @"Brown.jpg" },
@{ @"image": @"SlimFit.jpg" },
@{ @"image": @"SlimFit.jpg" },
@{ @"image": @"Brown.jpg" },
@{ @"image": @"Black.jpg" },
@{ @"image": @"Brown.jpg" },
@{ @"image": @"SlimFit.jpg" }
],
@"itemname": @[ @{ @"name": @"SlimFit"},
@{ @"name": @"BrownSlimFit"},
@{ @"name": @"SlimFit"},
@{ @"name": @"BrownSlimFit"},
@{ @"name": @"SlimFit"},
@{ @"name": @"SlimFit"},
@{ @"name": @"BrownSlimFit"},
@{ @"name": @"SlimFit"},
@{ @"name": @"BrownSlimFit"},
@{ @"name": @"SlimFit"}
],
@"itemprice": @[ @{ @"price": @"1499"},
@{ @"price": @"1599"},
@{ @"price": @"1399"},
@{ @"price": @"1599"},
@{ @"price": @"1499"},
@{ @"price": @"1499"},
@{ @"price": @"1599"},
@{ @"price": @"1399"},
@{ @"price": @"1599"},
@{ @"price": @"1499"}
],
},
];
//---UITableview--///
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [mensarrayimages count];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//return [modaldatabase.imagesArray count];
return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
// static NSString *cellidentifier [email protected]"cell";
MensCell *cell = [itemTableview dequeueReusableCellWithIdentifier:@"MensCell"];
//------ NSDictinary------
cellData = [mensarrayimages objectAtIndex:[indexPath section]];
priceData = [mensarrayimages objectAtIndex:[indexPath section]];
priceData1 = [mensarrayimages objectAtIndex:[indexPath section]];
//--- NSARRAY---
NSArray *articleData = [cellData objectForKey:@"articles"];
NSArray *itemnamedata = [priceData objectForKey:@"itemname"];
priceArr = [priceData1 objectForKey:@"itemprice"];
[cell setCollectionData:articleData];
[cell setCollectionData1:itemnamedata];
[cell setCollectionData2:priceArr];
return cell;
}
//------ UICollectionview ---///
//-- CollectionviewController--//
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [self.collectionarray count];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
CollectionCell1 *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionCell1" forIndexPath:indexPath];
NSDictionary *cellDataname = [self.collectionarray objectAtIndex:[indexPath row]];
NSLog(@"%@",cellDataname);
NSDictionary *cellDataimage = [self.arrayImage objectAtIndex:[indexPath row]];
NSLog(@"%@",cellDataimage);
NSDictionary *cellDataprice = [self.arrayprice objectAtIndex:[indexPath row]];
NSLog(@"%@",cellDataprice);
cell.ItemImageName.image =[UIImage imageNamed:[NSString stringWithFormat:@"%@",[cellDataimage objectForKey:@"image"]]];
cell.ItemName.text = [cellDataname objectForKey:@"name"];
cell.ItemPrice.text = [cellDataprice objectForKey:@"price"];
return cell;
}
UITableViewCell -> UICollectionviewController -> UICollectionviewCell.