UICollectionView reloadData not functioning properly in iOS 7

后端 未结 17 1369
北荒
北荒 2020-11-27 11:18

I\'ve been updating my apps to run on iOS 7 which is going smoothly for the most part. I have noticed in more than one app that the reloadData method of a

相关标签:
17条回答
  • 2020-11-27 11:55
     dispatch_async(dispatch_get_main_queue(), ^{
    
                [collectionView reloadData];
                [collectionView layoutIfNeeded];
                [collectionView reloadData];
    
    
            });
    

    it worked for me.

    0 讨论(0)
  • 2020-11-27 11:55

    Do you set UICollectionView.contentInset? remove the left and right edgeInset, everything is ok after I remove them, the bug still exists in iOS8.3 .

    0 讨论(0)
  • 2020-11-27 11:56

    Check that each one of the UICollectionView Delegate methods does what you expect it to do. For example, if

    collectionView:layout:sizeForItemAtIndexPath:
    

    doesn't return a valid size, the reload won't work...

    0 讨论(0)
  • 2020-11-27 11:58

    I also had this problem. By coincidence I added a button on top of the collectionview in order to force reloading for testing - and all of a sudden the methods started getting called.

    Also just adding something as simple as

    UIView *aView = [UIView new];
    [collectionView addSubView:aView];
    

    would cause the methods to be called

    Also I played around with the frame size - and voila the methods were getting called.

    There are a lot of bugs with iOS7 UICollectionView.

    0 讨论(0)
  • 2020-11-27 11:58

    try this code.

     NSArray * visibleIdx = [self.collectionView indexPathsForVisibleItems];
    
        if (visibleIdx.count) {
            [self.collectionView reloadItemsAtIndexPaths:visibleIdx];
        }
    
    0 讨论(0)
  • 2020-11-27 11:59

    I had exactly the same issue, however I managed to find what was going on wrong. In my case I was calling reloadData from the collectionView:cellForItemAtIndexPath: which looks not to be correct.

    Dispatching call of reloadData to the main queue fixed the problem once and forever.

      dispatch_async(dispatch_get_main_queue(), ^{
        [self.collectionView reloadData];
      });
    
    0 讨论(0)
提交回复
热议问题