0

Tools: xCode, Objective-C, Mac, Cocoa

Purpose: I am creating a collection view with many buttons. Each button opens a file in a folder and each of them has a background picture of the file (for example: jpeg file) so it looks like what you would see in a folder.

Question: How to make each button have a different image? Also, is this too difficult for a beginner?

P.S. : If i did this without the collectionview option, I would just drag the button on xib and change their background images, however I need my window to be collapsable and scrollable, hence I am using the collection view.

I would very much appreciate any comments/help/answers. Thanks!

1 Answers1

1

This should not be difficult. A CollectionView holds a collection of CollectionViewItems. Inside the Item you can create any views you need. One of them could be an NSImageView that you set at runtime to the image you like. I suggest to play around with CollectionView and some f the samples Apple provides on it.

harryhorn
  • 892
  • 6
  • 8
  • Thanks @harryhorn. I have played around with the Collection View, but still have questions. I understand that I create a Collection View Item with a button, but since I need the button to look different everytime, do I need to set that programmatically or adding more Collection View Items (if that's possible)? I am fine when it come to changing text of the items in the NScollectionview, etc, but not good with changing images... – ShaunArchibald May 18 '15 at 14:20
  • changing an image is no different than changing text. You set the relevant property with a new object. Good luck – harryhorn May 19 '15 at 04:45