1
votes

I have added a third collection view to my UIScrollView, which seems to be generating some noticeable scroll lag.

The view hierarchy is as follows (as I cant upload an image yet):

UIView
-->UIScrollView (large content size 230, 1100)
---->UIView for content
------>UIImageView (background image)
------>UIScrollView
------>UIView
------>PageControl
------>UICollectionView
------>UICollectionView
------>UICollectionView
------>Six labels

The actual UICollectionView's scroll really nicely horizontally, it's just the main UIScrollView has slight lag when scrolling up and down.

There was no lag at all before adding the third UICollectionView, which uses a different class for it's cells.

It seems there is only lag when all three collection views are on screen at one time.

The only delegate method implemented is scrollViewDidScroll, and simply resizes one of the subviews so I don't think this is affecting it at all.

It it simply because it can't cope with three UICollectionView's on screen at one time? I would have thought it could cope easy. Are there any obvious optimisations I can do?

1

1 Answers

3
votes

After a big headache and quite a lot of time, I've tracked down the issue. It had nothing to do with the collection views, they where simply highlighting the deeper problem.

I was adding some shadow effects to the view, I had no idea this had so much of a performance hit. It was even worse when the view controller this was is in was put in a navigation controller.

self.view.layer.shadowOpacity = 0.75f;
self.view.layer.shadowRadius  = 10.0f;
self.view.layer.shadowColor   = [UIColor blackColor].CGColor;

Anybody else having performance problems in UIScrollViews or UICollectionViews make sure to not make my mistake. Removing these three lines of code has not made scrolling super smooth.