how to bind data from server into collectionview which is inside uitableviewcell using hide and unhide functionality.on tap of uibutton i want to make colectionview visible and hide it again on the tap of button.What happens is when i scroll the tableview the data inside the collectionview skips from one cell to another making the collection view blank.

-(void)arrowButtonTapped:(UIButton *)donwbtn{

myob = [NSString stringWithFormat:@"%li", (long)donwbtn.tag];
NSLog(@"%@",myob);

NSIndexPath *  indexPath = [NSIndexPath indexPathForRow:0 
inSection:donwbtn.tag];

OppCell* celll = [_tableView cellForRowAtIndexPath:indexPath];
celll.collView.tag=donwbtn.tag;



if ([checkcoll containsObject:myob]) {
    [checkcoll removeObject:myob];
    celll.collView.hidden  = true;
    celll.collvwhght.constant=0;
    celll.colltop.constant=0;
    celll.collbottom.constant=0;
}

else
{
    [checkcoll addObject:myob];
    celll.collView.hidden = false;
    celll.collvwhght.constant=229;
    celll.colltop.constant=9;
    celll.collbottom.constant=8;
    [celll.collView reloadData] ;

  }


  [self.tableView beginUpdates];

   [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];

  [self.tableView endUpdates];

  }

    -(UITableViewCell *)tableView:(UITableView *)tableView 
  cellForRowAtIndexPath:(NSIndexPath *)indexPath{
   OppCell *cell = (OppCell *)[tableView 
    dequeueReusableCellWithIdentifier:@"OppCell"];

   NSString *theIndexpath = [NSString stringWithFormat:@"%ld", 
   (long)indexPath.section];

   if ([checkcoll containsObject:theIndexpath])
  {
    cell.collView.hidden = false;
    cell.collvwhght.constant=229;
    cell.colltop.constant=9;
    cell.collbottom.constant=8;


      if((![[[_Activitylistarray 

      objectAtIndex:indexPath.section]
      valueForKey:@"OpportunityContactInfoList"] 
     isKindOfClass:[NSNull class]])&&([[[_Activitylistarray 
     objectAtIndex:indexPath.section]
    valueForKey:@"OpportunityContactInfoList"]count]>0)){



        if(cell.contactdetailsarray == nil) {
            cell.contactdetailsarray =[[NSMutableArray alloc]init];
        for(NSDictionary * contactdict in 
      [[_Activitylistarray objectAtIndex:indexPath.section]
     valueForKey:@"OpportunityContactInfoList"] ){

          [cell.contactdetailsarray addObject:contactdict];
            [cell.collView reloadData];
        }

        }




      }

     }
   else
  {
    cell.collView.hidden  = true;
    cell.collvwhght.constant=0;
    cell.colltop.constant=0;
    cell.collbottom.constant=0;

  //  [cell.contactdetailsarray removeAllObjects];
   // [cell.collView reloadData];
  }

Thanks & Regards, Roshan.k

Related posts

Recent Viewed