Re: How to get variably sized header in a UICollectionView supporting both orientations
On Oct 4, 2013, at 11:35 AM, David Hoerl dho...@mac.com wrote: Becoming increasingly adept at autolayout but currently stumped. What I am trying to do is design a UICollectionView header that using constraints is suitable for portrait and landscape. 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? 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? As it stands now, what I'm doing is creating the header in code, and using knowledge of what orientation the view will be shown in, and varying the constraints on the container views. By reloading the collection view on every rotation, I can get a new (and properly) sized header. This seems like driving a nail with a sledgehammer, but nothing else comes to mind. Very open to suggestions on better methods. David ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/david.duncan%40apple.com This email sent to david.dun...@apple.com -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get variably sized header in a UICollectionView supporting both orientations
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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get variably sized header in a UICollectionView supporting both orientations
On Oct 4, 2013, at 1:52 PM, David Hoerl dho...@mac.com 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. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: How to get variably sized header in a UICollectionView supporting both orientations
On 10/4/13 5:09 PM, Steve Christensen wrote: On Oct 4, 2013, at 1:52 PM, David Hoerl dho...@mac.com 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 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com