UITableView is redrawing only some of custom cells
For quite a bit of time I am struggled with a kinda stupid problem. Hope someone can give me a hand.
UITableView is being implemented. The UITableViewCell is drawn in .xib and connected to a textEditCell property.
in the main program there is a simple code:
- (UITabl开发者_开发问答eViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return textEditCell;
}
Yet when the view is drawn, only some cells (after the view is started - last cell) is drawn. If the view is dragged beyond the top end of the screen, the top cell is been drawn, the bottom one is gone; when dragging to the bottom the behaviour is opposite.
Given the example in Apple cookbook? that is Listing 5-7. what am I doing wrong?
Appreciate your help.
What is described in Listing 5-7 only works if you only have one cell of that kind in your table. If you need many copies of that same cell then you should use the technique described in Listing 5-5.
Basically you're creating a single instance of a cell and trying to assign it to many rows. In the Apple cookbook you have a fixed number of custom cells, called cell0, cell1 instanced separately in the builder.
You would need to create another nib file to create your cells. Also remember about reusing cells - otherwise you will definitely have memory problems.
精彩评论