5

I want my UICollectionView to scroll when the contentSize.height becomes bigger than the contentOffset.y + frame.size.height, so I set up an observer, like so:

[self.collectionView addObserver:self 
                      forKeyPath:@"contentSize" 
                         options:0 
                         context:NULL];

I then have an NSLog to check it's contentSize.

The problem is that it doesn't update its contentSize until you add an additional panel after the one that just changed it. That means that it's contentSize is actually more than it says it is whenever the newest object stretches further down than any others.

Is this a common UICollectionView bug? Is there another way of seeing when it expands?

EDIT:

More info. This also happens when using

collectionView.collectionViewLayout.collectionViewContentSize.height 

and also happens if i call the NSLog after a few seconds of the new panel being displayed (so it's on screen and set up by that point). It still displays the wrong value.

Alex Cio
  • 6,014
  • 5
  • 44
  • 74
Andrew
  • 15,935
  • 28
  • 121
  • 203

0 Answers0