Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于demo中,vc3中不设置automaticallyAdjustsScrollViewInsets=false崩溃问题 #21

Closed
objcxiaobai opened this issue Feb 1, 2019 · 4 comments

Comments

@objcxiaobai
Copy link

No description provided.

@objcxiaobai
Copy link
Author

objcxiaobai commented Feb 1, 2019

因需求需要,跟着demo中vc3打,发现automaticallyAdjustsScrollViewInsets,这个属性在iOS11已经过期了(黄色警告,强迫症看着不爽,注释掉,发现跑不了),没有深入细看作者源代码,于是替换了以下代码(需求需要):
edgesForExtendedLayout = UIRectEdge.all;
navigationController?.navigationBar.isTranslucent = false;

@Danie1s
Copy link
Owner

Danie1s commented Feb 2, 2019

我找到问题了,由于是基于UIScrollView实现,那么就无法避免它的一些特性,问题已经解决,但引发了另外一个问题。
navigationBar.isTranslucent = true的时候,布局是从(0, 0)开始的,所以默认系统会给UIScrollView添加offset,iOS 11 以前就是automaticallyAdjustsScrollViewInsets 起作用,iOS 11以后引入SafeArea,由contentInsetAdjustmentBehavior管理
contentViewUICollectionView实现,所以这个特性会让UICollectionView的height小于item的高度,造成奇怪的bug
为什么其他例子中没有问题,估计是因为只有VC3里面修改了navigationBar
所以你最好要了解自己需要的布局效果是怎么样,我会尽快更新

@Danie1s Danie1s closed this as completed Feb 2, 2019
@objcxiaobai
Copy link
Author

objcxiaobai commented Feb 2, 2019

布局效果,就是让导航栏作为分段菜单(目前只知道这个方法,不知道有木有更好的方法),跟作者v3类似。
所以我用edgesForExtendedLayout = UIRectEdge.all;
navigationController?.navigationBar.isTranslucent = false;
替换了automaticallyAdjustsScrollViewInsets
实现了我想要的效果。
谢谢作者,知道了崩溃的原因了

@Danie1s
Copy link
Owner

Danie1s commented Feb 3, 2019

已经更新了,你可以参考demo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants