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: Richard Charles <email@hidden>
- Date: Sat, 06 Apr 2019 18:43:46 -0600
Cocoa Programming for Mac OS X Third Edition by Aaron Hillegass, Chapter 29
View Swapping.
Cocoa Programming for Mac OS X Fourth Edition by Aaron Hillegass, Chapter 31
View Swapping.
Cocoa Programming for Mac OS X Fifth Edition by Aaron Hillegass, Chapter 31
View Swapping and Custom Container View Controllers.
--Richard Charles
> On Apr 6, 2019, at 3:46 PM, 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