UICollectionView with ContentInset is not Scrolling all the Way Down

后端 未结 6 1643
长发绾君心
长发绾君心 2020-12-29 06:20

I am setting the content inset of a UICollectionView:

[_collectionView setContentInset:UIEdgeInsetsMake(0.f, 0.f, 100.f, 0.f)];

Then I am s

6条回答
  •  天涯浪人
    2020-12-29 07:16

    Possible Issue

    You have set the collectionView below the toolbar and added constraints to bottom of superview for both views.

    Solution

    Set the constraints of the toolbar to bottom, leading and set the width and height to fixed size. For your collectionView set the constraints to top, to bottom with the toolbar, leading to the superview and (alternative) with fixed size of width

    Update

    CollectionView

    Follow these steps to make it work:

    Check your collection view, and don't put it below toolbar, and add these constraints by selecting your collectionView on Document Outline, click ctrl and drag it to your view, a popup will appear, hold shift and select these constraints.

    CollectionView Constraints

    Toolbar

    Check the leading and bottom, by dragging with ctrl in view. And add fixed width and height for toolbar.

    Toolbar Constraints

    Dealing with scrolling before viewAppears

    -(void)viewWillAppear:(BOOL)animated
    {
        [collectionView reloadData];
        [self scrollToLastMessageAnimated:YES];
    }
    

提交回复
热议问题