iOS 9 CollectionView slowing down

守給你的承諾、 提交于 2019-12-21 20:37:13

问题


I have been developing my app for iOS8, and haven't really had any issues regarding the scrolling speed. The moment I have upgraded to iOS9 the collectionView became very jumpy and staggering. I cant point out to any specific reason why. In my collection view, I have items with images that uses 3rd party library (SDWebImage) and I also use a custom layout library to achieve double column layout. Is there any obvious reason why this could be happening?


回答1:


We were experiencing the same issues with collection views with iOS 9. The cells also contained images from SDWebImage including animated GIFs. It turned out not to be an issue with SDWebImage but with auto layout. If you have layout constraints with <= or >= inside your UICollectionViewCells (particularly on UITextViews, but still visible on UILabels, iOS 9 just chugs. Hope this helps someone.




回答2:


In this case the problem was about handling fallback images on the imageView.

Briefly, each item in the CollectionView has an UIImageView. Each UIImageView has a fallback image in case the actual image doesnt resolve (the url is broken for example). So, the way these fallback images set was wrong in my app! I have set images every time a collectionview item is rendered in the viewport.

UIImageView * fallback = [UIImage imageNamed:@"imageName"];

was called everytime, which makes the scroll staggered. Interestingly it wasnt an issue on iOS8 but only in iOS9.

So when I started reading from a precreated dictionary of images instead of creating a new one every time, the scroll view started become smooth again.

Hope this helps to those having the same issue.



来源:https://stackoverflow.com/questions/32724887/ios-9-collectionview-slowing-down

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!