0

I'm facing a strange bug on a UICollectionView when compiling for iOS7 and it's working good on iOS8.

I have a UICollectionView inside an UICollectionViewCell, and when I select that UICollectionViewCell I'm increasing the size of that cell so the UICollectionView inside of it, should increase its size too.

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    if (collectionView == _collectionView){
        NSLog(@"MainCell");
        UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MenuCell" forIndexPath:indexPath];

        UICollectionView * categoriesCollection = (UICollectionView*)[cell viewWithTag:2];

        [categoriesCollection reloadData];
        return cell;
    }else{
        NSLog(@"InsideCell");
        UICollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CategoryCell" forIndexPath:indexPath];

        cell.backgroundColor = CUSTOMCOLOR_BLACKGROUND_CELL_CATEGORY;

        UILabel * cellLabel = (UILabel*)[cell viewWithTag:11];
        cellLabel.text = @"TEST";

        return cell;
    }
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    if (collectionView == _collectionView){
        return 4;
    }else{
        return 12;
    }
}

View on iOS8. https://www.dropbox.com/s/49xuy3ehhneuaki/Captura%20de%20pantalla%202014-10-02%2015.46.56.png

View on iOS7. It shows the correct space for 12 rows, but only 1 is shown. And the child collectionview height is 30, but should be 360. https://www.dropbox.com/s/oncfyc42v7zjpds/Captura%20de%20pantalla%202014-10-02%2015.49.16.png

When compiling for iOS8 with iOS8 SDK or iOS7 SDK, prints "InsideCell" 12 times as it should be, but when I'm using iOS8 SDK for iOS7, it only prints "InsideCell" 4 times, with row 0 always. Is this an Apple Bug? Thanks

Fogmeister
  • 76,236
  • 42
  • 207
  • 306
hardlinkin
  • 101
  • 1
  • 8
  • What does `if (collectionView == _collectionView)` mean? Is `_collectionView` an instance variable that you are setting yourself? Post the code that sets it. – Greg Oct 02 '14 at 12:28
  • Yes, _collectionView is an IBOutlet property like this `@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;` – hardlinkin Oct 02 '14 at 13:42
  • Is this class a subclass of `UICollectionViewController`? If it is, your property declaration may be conflicting with internal implementation. Also, is there any particular reason you're comparing `collectionView` to `_collectionView` all the time? Are you using multiple collection views? – Greg Oct 02 '14 at 13:52
  • No, it's a normal UIViewController. The UICollectionViewCell inside the main `_collectionView` haves another UICollectionView (`categoriesCollection`). I've added 2 images comparing iOS7 & iOS8 – hardlinkin Oct 02 '14 at 13:54
  • Try assigning a value to the `tag` property of all of the nested collection views, and test the `tag` property instead of checking equality to `_collectionView`. – Greg Oct 02 '14 at 13:57
  • I've found that this is a bug from iOS8.0 and Xcode6, because I've installed Xcode 6.1 and I can't reproduce the bug on these.. Thanks Apple... :( – hardlinkin Oct 02 '14 at 14:22

1 Answers1

0

Seems iOS 8.0 and Xcode 6 bug, so in Xcode 6.1 it looks everything good in both iOS7 and iOS8. Thanks Apple...

hardlinkin
  • 101
  • 1
  • 8