ios - UICollectionView with ContentInset is not Scrolling all the Way Down -
i setting content inset of uicollectionview:
[_collectionview setcontentinset:uiedgeinsetsmake(0.f, 0.f, 100.f, 0.f)];
then scrolling programmatically way bottom of uicollectionview 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 scrolling down, ignoring contentinset, meaning last cells below specified content inset:
left image, shows how appear after view did appear. in right image, manually scrolled further down last message.
i using autolayout, ideas why happens?
edit:
here screenshot of ib setup:
today, chance discovered solution!
select view controller , uncheck option "adjust scroll view insets".
with option unchecked, ios not automatically adjust insets of view (and subviews), caused problems me ... uncheck , configure scroll insets programmatically:
- (void)configureinsetsofcollectionview { [_collectionview setcontentinset: uiedgeinsetsmake(self.navigationcontroller.navigationbar.bounds.size.height + [uiapplication sharedapplication].statusbarframe.size.height + default_spacing, 0.f, _keyboardheight + _toolbar.bounds.size.height + default_spacing, 0.f)]; [_collectionview setscrollindicatorinsets:uiedgeinsetsmake(self.navigationcontroller.navigationbar.bounds.size.height + [uiapplication sharedapplication].statusbarframe.size.height, 0.f, _keyboardheight + _toolbar.bounds.size.height, 0.f)]; }
Comments
Post a Comment