I have a custom UITableViewCell loaded from a nib file. Everything works fine until I scroll down past the last cell such that the table view has to bounce back when I let go.
Then, the cells towards the top of the list are blank and remain blank until I manually refresh the table view.
Image of issue: [iPhone Screenshot][1]
Here is my cell for row code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"TimeEntryCellIdentifier";
TimeEntryCell *cell = (TimeEntryCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"TimeEntryCell" owner:self options:nil];
for (id oneObject in nib) {
if ([oneObject isKindOfClass:[TimeEntryCell class]]) {
cell = (TimeEntryCell *) oneObject;
}
}
}
TimeEntry *aTimeEntry = [appDelegate.timeEntries objectAt开发者_JS百科Index:indexPath.row];
cell.clientName.text = aTimeEntry.ClientName;
cell.category.text = aTimeEntry.CategoryName;
cell.hours.text = [NSString stringWithFormat:@"%@", aTimeEntry.Hours];
[TimeEntry release];
return cell;
}
Any ideas?
[1]: http://dl.nvthost.com.s3.amazonaws.com/Screen shot 2011-02-18 at 2.46.42 PM.png
[1]: http://dl.nvthost.com.s3.amazonaws.com/Screen shot 2011-02-18 at 2.46.42 PM.png
I don't think you should be doing the
[TimeEntry release];
there on the next to last line. You didn't allocate it in that method, just pulled a reference from the delegate. The retain count is probably zero at that point. When iOS starts releasing memory that TimeEntry will be dealloc'd.
The problem turned out the be the view hierarchy in IB. Even though I put a view in the cell and then dragged UILabels onto the view, they ended up on the same level as the view. After I moved the UILabels under the view it appears to be working.
精彩评论