I am setting the content inset of a UICollectionView:
[_collectionView setContentInset:UIEdgeInsetsMake(0.f, 0.f, 100.f, 0.f)];
Then I am scrolling programmatically all the way to the bottom of the UICollectionView with this method:
- (void)scrollToLastMessageAnimated:(BOOL)animated;
{
if (_messages.count == 0) { return; }
NSUInteger indexOfLastSection = _messagesBySections.count - 1;
NSInteger indexOfMessageInLastSection = [_messagesBySections[indexOfLastSection] count] - 1;
NSIndexPath *path = [NSIndexPath indexPathForItem:indexOfMessageInLastSection
inSection:indexOfLastSection];
[_collectionView scrollToItemAtIndexPath:path
atScrollPosition:UICollectionViewScrollPositionCenteredVertically
animated:animated];
}
It is scrolling down, but it is ignoring the contentInset, meaning that the last cells are below the specified content inset:
The left image, shows how it appear now after the view did appear. In the right image, I manually scrolled further down to the last message.
I am using AutoLayout, any ideas why this happens?
EDIT:
Here is a screenshot of the IB setup: