Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding image cell is in kk grid view #157

Open
martinfreefall opened this issue Jan 7, 2013 · 6 comments
Open

adding image cell is in kk grid view #157

martinfreefall opened this issue Jan 7, 2013 · 6 comments

Comments

@martinfreefall
Copy link

How do I add images to cells in kkgrid view ?

@kolinkrewinkel
Copy link
Owner

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.

@martinfreefall
Copy link
Author

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

@kolinkrewinkel
Copy link
Owner

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.

@martinfreefall
Copy link
Author

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];
    }

@zadr
Copy link
Contributor

zadr commented Jan 9, 2013

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

@martinfreefall
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants