<bdo id='8aNcR'></bdo><ul id='8aNcR'></ul>
  • <legend id='8aNcR'><style id='8aNcR'><dir id='8aNcR'><q id='8aNcR'></q></dir></style></legend>

        <i id='8aNcR'><tr id='8aNcR'><dt id='8aNcR'><q id='8aNcR'><span id='8aNcR'><b id='8aNcR'><form id='8aNcR'><ins id='8aNcR'></ins><ul id='8aNcR'></ul><sub id='8aNcR'></sub></form><legend id='8aNcR'></legend><bdo id='8aNcR'><pre id='8aNcR'><center id='8aNcR'></center></pre></bdo></b><th id='8aNcR'></th></span></q></dt></tr></i><div id='8aNcR'><tfoot id='8aNcR'></tfoot><dl id='8aNcR'><fieldset id='8aNcR'></fieldset></dl></div>

        <small id='8aNcR'></small><noframes id='8aNcR'>

        <tfoot id='8aNcR'></tfoot>
      1. 带有 ContentInset 的 UICollectionView 不会一直向下滚动

        UICollectionView with ContentInset is not Scrolling all the Way Down(带有 ContentInset 的 UICollectionView 不会一直向下滚动)

        <small id='w0SEY'></small><noframes id='w0SEY'>

          <tfoot id='w0SEY'></tfoot>
              <bdo id='w0SEY'></bdo><ul id='w0SEY'></ul>
              1. <i id='w0SEY'><tr id='w0SEY'><dt id='w0SEY'><q id='w0SEY'><span id='w0SEY'><b id='w0SEY'><form id='w0SEY'><ins id='w0SEY'></ins><ul id='w0SEY'></ul><sub id='w0SEY'></sub></form><legend id='w0SEY'></legend><bdo id='w0SEY'><pre id='w0SEY'><center id='w0SEY'></center></pre></bdo></b><th id='w0SEY'></th></span></q></dt></tr></i><div id='w0SEY'><tfoot id='w0SEY'></tfoot><dl id='w0SEY'><fieldset id='w0SEY'></fieldset></dl></div>

                  <tbody id='w0SEY'></tbody>

                • <legend id='w0SEY'><style id='w0SEY'><dir id='w0SEY'><q id='w0SEY'></q></dir></style></legend>
                  本文介绍了带有 ContentInset 的 UICollectionView 不会一直向下滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在设置 UICollectionView 的内容插入:

                  I am setting the content inset of a UICollectionView:

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

                  然后我用这个方法以编程方式一直滚动到 UICollectionView 的底部:

                  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];
                  }
                  

                  它是向下滚动,但是它忽略了contentInset,意味着最后一个单元格在指定的content inset之下:

                  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.

                  我正在使用 AutoLayout,你知道为什么会这样吗?

                  I am using AutoLayout, any ideas why this happens?

                  这是 IB 设置的屏幕截图:

                  Here is a screenshot of the IB setup:

                  推荐答案

                  今天偶然发现了解决方案!

                  Today, by chance I discovered the solution!

                  选择您的视图控制器并取消选中调整滚动视图插图"选项.

                  Select your view controller and uncheck the option "Adjust Scroll View Insets".

                  如果未选中此选项,iOS 不会自动调整视图的插图(可能还有它的子视图),这给我带来了问题...取消选中它并像这样以编程方式配置滚动插图:

                  With this option unchecked, iOS does not automatically adjust your insets of the view (and probably its subviews), which caused the problems for me ... Uncheck it and configure your scroll insets like this 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)];
                  }
                  

                  这篇关于带有 ContentInset 的 UICollectionView 不会一直向下滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  iOS AutoLayout - get frame size width(iOS AutoLayout - 获取帧大小宽度)
                  Auto layout constraints issue on iOS7 in UITableViewCell(UITableViewCell中iOS7上的自动布局约束问题)
                  How to resize superview to fit all subviews with autolayout?(如何调整超级视图的大小以适应所有具有自动布局的子视图?)
                  Springs in Auto Layout: Distribute views evenly, with constraints, in Xcode 5(自动布局中的弹簧:在 Xcode 5 中使用约束均匀分布视图)
                  reloadData() of UITableView with Dynamic cell heights causes jumpy scrolling(具有动态单元格高度的 UITableView 的 reloadData() 导致跳跃滚动)
                  What is NSLayoutConstraint quot;UIView-Encapsulated-Layout-Heightquot; and how should I go about forcing it to recalculate cleanly?(什么是 NSLayoutConstraint“UIView-Encapsulated-Layout-Height?我应该如何强制它干净地重新计算?) - IT屋-程序员
                  • <small id='0iXMT'></small><noframes id='0iXMT'>

                      <tbody id='0iXMT'></tbody>
                      <bdo id='0iXMT'></bdo><ul id='0iXMT'></ul>

                        • <i id='0iXMT'><tr id='0iXMT'><dt id='0iXMT'><q id='0iXMT'><span id='0iXMT'><b id='0iXMT'><form id='0iXMT'><ins id='0iXMT'></ins><ul id='0iXMT'></ul><sub id='0iXMT'></sub></form><legend id='0iXMT'></legend><bdo id='0iXMT'><pre id='0iXMT'><center id='0iXMT'></center></pre></bdo></b><th id='0iXMT'></th></span></q></dt></tr></i><div id='0iXMT'><tfoot id='0iXMT'></tfoot><dl id='0iXMT'><fieldset id='0iXMT'></fieldset></dl></div>
                          <legend id='0iXMT'><style id='0iXMT'><dir id='0iXMT'><q id='0iXMT'></q></dir></style></legend>
                          <tfoot id='0iXMT'></tfoot>