UITableView with a single custom Cell? (iPhone)?

I think the problem is not that the first off-screen cell is at indexPath. Row = 0 The problem is that you are using the same CellIdentifier for regular and custom cells. So when the TableView goes to dequeue a cached cell, it is sometimes grabbing your custom cell that has the icon in it Since you gave it the same CellIdentifier as your regular cells, it doesn't know that they are not the same Something like this should fix it: static NSString *CellIdentifier; if(indexPath row == 0){ CellIdentifier = @"CustomCell"; } else { CellIdentifier = @"Cell"; } I'm not sure about your edit button problem, but it could be related.

I think the problem is not that the first off-screen cell is at indexPath. Row = 0. The problem is that you are using the same CellIdentifier for regular and custom cells.So when the TableView goes to dequeue a cached cell, it is sometimes grabbing your custom cell that has the icon in it.

Since you gave it the same CellIdentifier as your regular cells, it doesn't know that they are not the same. Something like this should fix it: static NSString *CellIdentifier; if(indexPath row == 0){ CellIdentifier = @"CustomCell"; } else { CellIdentifier = @"Cell"; } I'm not sure about your edit button problem, but it could be related.

Yes in retrospective, I am also quite sure that is what happened. The approach of if(indexPath. Row == 0) is correct.

Building a custom cell for the first row and using a different identifier is the right way to go. – RickiG Mar 12 at 10:35.

My problem is now that the first Cell in my tableView is different than the others. I has a special icon and other things that separates it from the other cells. This is a bad idea as the tableView lazy loads the cells and therefore the first cell that is off-screen, when being scrolled on-screen, will also get indexPath.

Row = 0 so now I have a "special cell" for every 7 cells. How do I get around this one? A second problem that also originates from the above: I have a custom UIView placed in all the cells accessoryView.

When the user taps an "Edit" button, all the cells accessoryViews should change to an icon indicating that we are in "Edit mode". Here, again, this only happens for the cells on screen, when scrolling "old" cells are either fetched from cache or new cells are build that doesn't know we are in edit mode. When You tap a Cell, there is never any doubt about the indexPath.

Row of the cell tapped, this index you need to pair with your model array to figure out what the user tapped. But it seems different rules apply when the TableView is manipulating the cells (pulling them on-screen, off-screen, deleting, adding). I guess, I am asking; to follow best practice and not fight the SDK, what should I do to obtain the desired functionality and at which stage in the Cell life-cycle should I apply this logic?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions