Geoff
Geoff

Reputation: 51

Matching widths for Autolayout views in separate hierarchies

I am trying to build a spreadsheet like app which has a scroll view and "floating" headers on the top and left which do not scroll with the rest of the content. I have this implemented in a ScrollView using layoutSubViews to override the frames of the header UIViews, with all the scrolling in a single UIView:

This is all working great, except where the items in the header need to line up with the main content (i.e., "W:cell1==topHeader1", "H:cell1==leftHeader1", etc.). Autolayout won't allow constraints since the items are not in the same hierarchy. How do I keep the widths/heights the same?

Upvotes: 2

Views: 53

Answers (1)

mohamede1945
mohamede1945

Reputation: 7198

I think it's better implementing this scenario using UICollectionView, if the default UICollectionViewFlowLayout won't satisfy your requirement subclass it or even create a whole new custom layout.

Such scenario is definitely for CollectionView, it will add reusability for the visible cells. So that if you have hundreds of rows/columns, you don't use extra memory.

Upvotes: 1

Related Questions