automaticallyAdjustsScrollViewInsets深坑

automaticallyAdjustsScrollViewInsets

1、这个属性没设置,居然引发

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath

不走(ios 8.2 && ios 9.3.2)

2、第一个加进入的是滑动视图时,要特别小心,可能内容被导航栏调整没了,你要小心。

不管你的高度设置多高,都给你调整没了,这maybe是苹果的一个bug.

3、UIScrollViewContentInsetAdjustmentBehavior

注意是内容,你要注意哈。

4、UIScrollViewContentInsetAdjustmentAutomatic, // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable

顶部和底部都会被适应

5、这个属性是解决内容遮挡问题的

以下参老文章:

作者:简书小王子6040

链接:https://www.jianshu.com/p/a1987a7c11ba

来源:简书

简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

https://www.jianshu.com/p/a1987a7c11ba

6、edgesForExtendedLayout:边缘延伸属性,默认为UIRectEdgeAll。它也是视图控制器的布局属性,默认值是UIRectEdgeAll,即:当前视图控制器里各种UI控件【本身】(而非内容)会忽略导航栏和标签的存在,布局时若设置其原点设置为(0,0),视图会延伸显示到导航栏的下面被覆盖;其值为UIRectEdgeNone意味着子控件本身会自动躲避导航栏和标签栏,以免被遮挡。

7、UINavigationBar与UITabBar默认都是半透明模糊效果,在这种情况下系统会对视图控制器的UI布局进行优化:当视图控制器里面【第一个】被添加进去的视图是UIScrollView或其子类时,系统会自动调整其内边距属性contentInset,以保证滑动视图里的内容不被UINavigationBar与UITabBar遮挡。

8、写的很棒 我在进一步总结一下,请大佬帮忙看看对不对:

1. 当UINavigationBar的translucent为YES时(默认值),控件的坐标从屏幕最上方开始计算,即(0,0)

2. 当UINavigationBar的translucent为NO时,控件的坐标从导航栏左下方开始计算,即(0,64)或者(0,88)

3. 当设置automaticallyAdjustsScrollViewInsets为YES时(默认值),滚动视图的内容会自动避开导航条。

4. 当设置automaticallyAdjustsScrollViewInsets为NO时,滚动视图的内容会从顶部开始展示。

5. edgesForExtendedLayout:边缘延伸属性,默认为UIRectEdgeAll,控制self.view的显示范围。

self.edgesForExtendedLayout = UIRectEdgeNone; //从navigationBar下面开始计算一直到屏幕tabBar上部

self.edgesForExtendedLayout = UIRectEdgeAll; //从屏幕边缘计算(默认)

self.edgesForExtendedLayout = UIRectEdgeTop; //navigationBar下面开始计算一直到屏幕tabBar上部

self.edgesForExtendedLayout = UIRectEdgeBottom; //从navigationBar下面开始计算一直到屏幕底部

9、结论就是不需要考虑导航栏遮掩,我们就需要设置automaticallyAdjustsScrollViewInsets 为NO,不可缺少。否则可能会引发问题。

other article :

https://www.jianshu.com/p/ea9e19b7d69f

猜你喜欢

转载自blog.csdn.net/u014544346/article/details/93886453