Re: How to get variably sized header in a UICollectionView supporting both orientations
Re: How to get variably sized header in a UICollectionView supporting both orientations
- Subject: Re: How to get variably sized header in a UICollectionView supporting both orientations
- From: David Hoerl <email@hidden>
- Date: Fri, 04 Oct 2013 16:52:11 -0400
I have a bunch of views in it, each grouped into a container view. What I'd like to do is when the view rotates, move the container views around. Currently this seems impossible because the size of the header (and footer) must be specified to the Flow Layout before the view is even created, and it appears to be fixed from them on.
Do you mean the header/footerReferenceSize properties?
No
If so I would think this would just work, since the flow layout will
automatically size the width or height (depending on the scrolling
direction) to fill the width or height of the collection view, allowing
your container to just specify its sizes relative to the parent view
size without needing to know the orientation.
But maybe I just don’t understand exactly what you are running up against?
I have two sections, so have to use the Flow Delegate callback to supply
the sizes:
- (CGSize)collectionView:(UICollectionView *)collectionView
layout:(UICollectionViewLayout*)collectionViewLayout
referenceSizeForHeaderInSection:(NSInteger)section
The Flow Layout object asks for the sizes first, then the header (or
footer if used). I tried returning one size in the above delegate
method, then a larger header, but the collection view does not appear to
look at the view's size, instead honoring the delegate returned value.
Hmmm - it looks like I overlooked sending the layout object
"invalidateLayout". I just did that in the willAnimate... rotation view
controller method, and I observe the layout object asked again the the
header height.
But its really odd - and I'm thinking about a bug report on this - that
the delegate has to provide the size before the view is even created. So
what I do now is create a header view in view did load, ask it for its
size using systemLayoutSizeFittingSize, then release it, just to get the
size (its using the new dynamic text so this is the only way to get its
size). Later, Flow Layout asks for the size, then in another delegate
call I dequeue a header view whose size I now know. I tried to cache the
first view but that failed.
--
David Duncan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden