2016-04-04 21 views
-2

UICollectionviewcell.my Veri'de bir UIImageview ve iki UILables yaratıyorum NSArray'da saklanan ve format NSDictionary, anahtar ve değerlerdir. ancak UICollectionviewCell'de veriler gösterilmemiştir. Bu benim Kodumdur.Veriler UICollectionviewcell'de görüntülenmiyor mu?

//---- 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.

cevap

0

Bu oldukça belirsiz bir sorudur. Ancak, belki UI yapısı biraz kapalı mı?

UITableView -> UICollectionViewController -> UICollectionViewCell 

Henüz birisini denemediğim bir şey var. Burada görebildiğim kadarıyla, basit bir UITableView veya UICollectionView kullanmaya, ancak her ikisini de aynı anda kullanmamalısınız. Şekilde kullanın:

UITableViewController -> UITableView -> UITableViewCell 

veya

UICollectionViewController -> UICollectionView -> UICollectionViewCell 

Ben UITableViews koduna genellikle daha kolay olduğu için ilk gidiyor önermek ve

sürdüreceğini