Custom Cells in UITable randomly blank
I have a UITable with a custom UITableCell. When the table displays most of the items are blank except for the disclosure triangle. As I scroll up and down cells randomly turn on and off, but at any given moment, most are blank.
Additional information: 1) It is the "right cell". When I click on the disclosure, it goes to th开发者_如何学编程e right place. 2) I used the exact same code in another table and it works fine. (Yes, I changed all the variables including the cell identifier. 3) I have disabled reuse of cells, the problem is still there. 4) I have used dummy strings in my cell, the problem is still there 5) The cell is created from a nib.
Here is the code in question (version shown doesn't use reuse cells and has dummy text in variables.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *announcementCellIdentifier = @"AnnouncementCellIdentifier";
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AnnouncementCell" owner:self options:nil];
AnnouncementCell *cell = [nib objectAtIndex:0];
NSUInteger row = [indexPath row];
NSArray *keylist = [[NSArray alloc] init];
if ((tableView == self.tableView)) {
keylist = announcementsInCommunity;
} else {
keylist = filteredAnnouncementNames;
}
…
cell.announcementCreationTimeLabel.text = @"00/00/00";
cell.announcementCreatorLabel.text = @"The Creator";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.announcementSubjectLabel.text = @"Subject";
return cell;
}
I'm not sure, but normally we can use owner:nil
when loading nib like this. I still don't see anything other thing that might cause the issue, but it might be in the code section that you omitted as well.
I decided there had to be something wrong in the nib file, but I couldn't find it. Finally, I deleted the .xib and started over. Now it works fine.
I had the same problem. In my case, the problem is that the controller have 2 outlets pointing to the same customCell. Don't know how that extra pointer can be an issue.
精彩评论