• the item height must be less than the height of 导航下scrollview产生偏移的问题


    最近用UICollectionView写了一个卡片轮播,ios12上效果完美,在ios10上跑了一下发现视图出现偏移,效果如下图

    找了好久原因最后发现在ios10上控制台打印了如下提示内容

     The behavior of the UICollectionViewFlowLayout is not defined because:
     the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
     The relevant UICollectionViewFlowLayout instance is <CollectionFlowLayout: 0x7f83d7d5d230>, and it is attached to <UICollectionView: 0x7f83d8111000; frame = (0 0; 375 160); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x600000058ba0>; layer = <CALayer: 0x600000221460>; contentOffset: {0, 0}; contentSize: {126, 111}> collection view layout: <CollectionFlowLayout: 0x7f83d7d5d230>.
     Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

    上网查了下原因发现在ios11以下系统中导航控制器下当self.automaticallyAdjustsScrollViewInsets = YES;时,控制器下的scrollview的contentInset会默认向下偏移64,所以把这个属性设为NO就可以了,希望对遇到同样问题的朋友有帮助

  • 相关阅读:
    17.CSS 文本属性和字体属性
    15.CSS 浮动
    D. Same GCDs
    B. Infinite Prefixes
    D. 0-1 MST
    lambda表达式复习
    D. New Year and Conference
    C. New Year and Permutation
    D. Dr. Evil Underscores
    D. Minimax Problem
  • 原文地址:https://www.cnblogs.com/zk1947/p/10338728.html
Copyright © 2020-2023  润新知