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

dequeueReusableCellWithIdentifier bug ? #79

Open
KMindeguia opened this issue Jul 7, 2011 · 1 comment
Open

dequeueReusableCellWithIdentifier bug ? #79

KMindeguia opened this issue Jul 7, 2011 · 1 comment

Comments

@KMindeguia
Copy link

Hi,

I'm currently using AQGridView for a project. I have 16 cells in the grid. dequeueReusableCellWithIdentifier should then return 16 nil cells, but I only get 8...

Here is my cellForItemAtIndex method :


- (AQGridViewCell_) gridView:(AQGridView *)aGridView cellForItemAtIndex:(NSUInteger)index
  {
  static NSString_ myIdentifier = @"MiniPola";
  ImageDemoGridViewCell\* cell = (ImageDemoGridViewCell_)[aGridView dequeueReusableCellWithIdentifier:myIdentifier];
  if (cell == nil)
  {
      //Should pass here 16 times but only does 8 times...
      cell = [[[ImageDemoGridViewCell alloc] initWithFrame:CGRectMake(0, 0, 171, 199) reuseIdentifier:myIdentifier] autorelease];
     // I would Like to set my cell's Photo and Profile here to get a smooth scrolling...
  }
  [cell setTitle:[[contentArray objectAtIndex:index]objectForKey:@"title"]];
  [cell setPhoto:[[contentArray objectAtIndex:index] objectForKey:@"picture"]];
  [cell setProfile:[[[contentArray objectAtIndex:index] objectForKey:@"from"] objectForKey:@"picture"]];
  NSNumber_ temp = [NSNumber numberWithInt:index];
  cell.cellIndex = temp;
  return cell;
  }

Thanks for your help !

@evadne
Copy link
Collaborator

evadne commented Aug 22, 2011

I think the times the grid view does not have a cached and reusable cell depends on the size of the grid view, the number of cells it ought to show, etc., and if you’re using the same reuse identifier, then it’s almost guaranteed to be working… If you want every single cell cached and no reusing, you can consider using [NSString stringWithFormat:@"%@-%i", myIdentifier, index] — but this is really not recommended because cell creation is relatively costly.

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

2 participants