Re: Dynamically change NSCollectionView items based on view width
Re: Dynamically change NSCollectionView items based on view width
- Subject: Re: Dynamically change NSCollectionView items based on view width
- From: Mike Abdullah <email@hidden>
- Date: Sun, 07 Apr 2019 21:20:28 +0100
The obvious first question to me is: is your notification actually firing?
Mike.
> On 6 Apr 2019, at 22:46, Demitri Muna <email@hidden> wrote:
>
> Hello,
>
> I have a 10.11+ NSCollectionView. I have two representations (subclasses of
> NSCollectionViewItem) of the data - one large and one small. When the view is
> resized to be narrower than the large representation, I’d like to swap the
> views to the smaller versions. Similarly, when the window is widened enough
> to accommodate at least a single of the larger views, I’d like the views to
> change again. I’ve not been able to make this work.
>
> I have set up an NSViewBoundsDidChangeNotification so I know when the width
> of the view crosses the threshold. I’ve tried:
>
> - [collectionView reloadData]
> - [collectionView.collectionViewLayout invalidateLayout] (on the
> NSCollectionViewFlowLayout)
>
> I think I just want to invalidate all of the already created views and get
> the collection view to call makeItemWithIdentifier:forIndexPath: again.
>
> One option I haven’t explored is to handle the change within a single
> NSCollectionViewItem subclass (two views in the one .xib), but since the
> representations are sufficiently different (e.g different number of subviews)
> I’m worried about running into auto layout issues during the transition. Also
> it feels messier.
>
> Bonus points for how to accomplish this with animation!
>
> Thanks,
> Demitri
>
> _______________________________________________
>
> 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
_______________________________________________
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