Autoresizing subview to text length inside NSCollectionView
-
19-10-2022 - |
Question
I have an NSCollectionView. My example subviews are simple, basically a Label with a box around them.
I would like my subviews to resize their width to fit the label length. For example, if we have "banana", "tomato" and "pig", i.e.,
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
self.listObjArray = [NSArray arrayWithObjects:@"banana", @"tomato", @"pig", nil];
}
the CollectionView (bound to Array Controller bound to listObjArray) should show
[banana] [tomato] [pig]
instead of
[bana] [toma] [pig ]
How can I do this? As a bonus, I would like the subview to increase in size no larger than the CollectionView width, so that I have I have a really long text, I would end up with
[thisisareallysuperlongkindofst...]
[banana] [tomato] [pig]
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow