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: Steve Christensen <email@hidden>
- Date: Fri, 04 Oct 2013 17:03:38 -0700
On Oct 4, 2013, at 2:45 PM, David Hoerl <email@hidden> wrote:
> On 10/4/13 5:09 PM, Steve Christensen wrote:
>> On Oct 4, 2013, at 1:52 PM, David Hoerl <email@hidden> wrote:
>>
>>> 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.
>>
>> It make sense if you think about it: it's asking for sizes so that scroll view contentSize can be set and the layout can be determined. It would be a lot more expensive to have to actually build each of the cells for the entire collection just to get their sizes. This sort of behavior also happens with UITableView and its various cells.
>
> In the old days, you had static views. Now with dynamic type, and the ability to more easily support different dynamic portrait/landscape layouts (with autolayout), the views can change a lot. Also, for table headers and footers, you created the view then set or returned it.
>
> With Collections you have to "dequeue" it, and ostensibly you can only do this when asked for a cell (since there is no way I know to dequeue a view then tell the collection that you don't really need it after all).
>
> Maybe I could dequeue one early on, cache it to get the sizes, and the first time only I'm asked for the view, return the cached one (then nil out the reference). This seems like it might work but IMHO would be "risky" in terms of stretching the API.
>
> I will probably at least try that out when I get everything else working.
>
> David
You could also do something like add a class method to your cell class that creates a non-queued instance (if necessary to the calculation) and calculates the cell height based on whatever goes into determining it. That avoids mucking around with the collection view's queue.
_______________________________________________
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