KKGridView icon indicating copy to clipboard operation
KKGridView copied to clipboard

adding image cell is in kk grid view

Open martinfreefall opened this issue 12 years ago • 6 comments

How do I add images to cells in kkgrid view ?

martinfreefall avatar Jan 07 '13 09:01 martinfreefall

Add a subview-UIImageView as a property and set its image.

On Jan 7, 2013, at 1:24 AM, martinfreefall [email protected] wrote:

How do I add images to cells in kkgrid view ?

— Reply to this email directly or view it on GitHub.

kolinkrewinkel avatar Jan 07 '13 16:01 kolinkrewinkel

[cell.contentView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tux.png"]]]; ??

martinfreefall avatar Jan 08 '13 06:01 martinfreefall

As long as you're only doing this once, that'll work. Otherwise, you'll encounter an infinite subviews problem (for example if you do this on every call to cellForItemAtIndex:).

On Jan 7, 2013, at 10:17 PM, martinfreefall [email protected] wrote:

[cell.contentView addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tux.png"]]]; ??

— Reply to this email directly or view it on GitHub.

kolinkrewinkel avatar Jan 08 '13 08:01 kolinkrewinkel

http://i1275.photobucket.com/albums/y447/martinfreefall/2013-01-08163341_zps1d72eb00.png

every cell is supposed to have the penguin . but only the last one gets populated

my code is like this

viewdidload { viewForcell = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tux.png"]]; }

  • (KKGridViewCell *)gridView:(KKGridView *)gridView cellForItemAtIndexPath:(KKIndexPath *)indexPath { [cell.contentView addSubview:viewForcell]; }

martinfreefall avatar Jan 08 '13 11:01 martinfreefall

A view can only be on screen once at a time; you should use a separate image view for every cell as its dequeued.

zadr avatar Jan 09 '13 20:01 zadr

@zadr when using that im getting images that are over layed on each other

martinfreefall avatar Jan 10 '13 06:01 martinfreefall