Hi I m using two collection cell to display data, Child Collection view values are based on main Collection View.
I have Video List and when i select Video In Table i m passing Complete array at index path, so that the main collection view will be displayed based on selected indexPath of array.
it is displaying fine, but when i scroll it horizontal, I an passing visible cell indexPath data to fetch child collection View Data.
But when i scroll Main Collection View , The array at indexPath is not updating based on Main Collection View it always display same IndexPath which is Passed From Video List(Previous View Controller).
How to update main collection view array based on horizontal Scrolling.
I want ion this scenario-
For example VIdeo list array is 1,2,3,4
i select 3 index and pass to collection view for videolist array, it displayed selected index path row value, when i scroll right side the index path should get increased to 4 on right and left it should decrease to 2, for any values selected on video list array. Main Collection view should work based on passed index path and act based on its index path
My Code-
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
if(self.childCollectionView ==collectionView)
{
return [self.array_ChildElements count];
}
else
{
return [self.array_VideoList count];
}
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
if (collectionView ==self.collectionView)
{
VVCollectionCell *cell = (VVCollectionCell *)[self.collectionView dequeueReusableCellWithReuseIdentifier:@"VVCollectionCell" forIndexPath:indexPath];
VVSystems *obj;
if (self.iscalledFromVideoLIst)
{
obj =self.array_VideoList[self.selectedIndexPath.row];
}
else
{
obj =self.array_VideoList[indexPath.row];
}
[self.collectionView flashScrollIndicators];
NSLog(@"Current Index Path--->%ld",(long)self.selectedIndexPath.row);
NSLog(@"Current Title--->%@",obj.title);
[cell.labelVideoTitle setText:obj.title];
[cell.imgVideo sd_setImageWithURL:[NSURL URLWithString:obj.iconImage]
placeholderImage:nil];
return cell;
}
else
{
childCollectionCell *cell2 = (childCollectionCell *)[self.childCollectionView dequeueReusableCellWithReuseIdentifier:@"childCollectionCell" forIndexPath:indexPath];
ChildAnimations *obj = self.array_ChildElements[indexPath.row];
[self.childCollectionView flashScrollIndicators];
[cell2.labelTitel setText:obj.tagName];
[cell2.imgbackGround sd_setImageWithURL:[NSURL URLWithString:obj.image]
placeholderImage:nil];
return cell2;
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
for (VVCollectionCell *cell in [self.collectionView visibleCells])
{
NSIndexPath *newIndexPath = [self.collectionView indexPathForCell:cell];
VVSystems *objCustVehiclesList =self.array_VideoList[newIndexPath.row];
NSLog(@"Current Index Path Row -->%ld",(long)newIndexPath.row);
NSLog(@"Current Title--->%@",objCustVehiclesList.title);
self.str_partID =objCustVehiclesList.partID;
[self ServiceCallForChildVideo:self.str_partID];
self.iscalledFromVideoLIst = NO;
}
}