UITableViewCell and strange behaviour in grouped UITableView
I'm working on a grouped UITableView, with 4 sections with one row per section, and have a strange behaviour with the cells. The cells are plain UITableViewCells, but the height of the cells are around 60 - 80 pixel. Now the tableview renders the cells correct with round corners, but when I select the cells, they appear blue and rectangle. I don't know why the cells behave like this, because I have another grouped UITableView with custom cells and 88 pixel height and those cells work like they should.
If I change the height to the default height of 44 pixel, the cells behave like the should. Does anyone know about this behaviour and what the cause is?
Like I mentioned, I don't do any fancy stuff I use default UITableViewCells in a static, grouped UITableView with 4 sections with 1 row in each section.
evangelion2100
Edit: OK, here are the relevant parts of my code. Because I only use a fixed number of cells for this tableview I store the cells in a 2d NSMutableArray. I set up the cells in the -(void)viewDidLoad method and the respective delegate Methods access the Array with the stored cells.
I don't see anything that would cause this strange behaviour of the cells if they get selected.
Edit2: Sorry the reason why I store the cells in an array is not only the among of cells. If the view changes and UITableView reappears, the cells will be exchanged with custom cells. That the real reason for the storage of the cells. It's like some kind of "add new email"-Type of behaviour, like in the contact app from the iphone.
-(void)viewDidLoad {
// set up the AccompanyingLecture cell
UITableViewCell *accompanyingLectureCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"AccompanyingLectureCell"];
accompanyingLectureCell.textLabel.textAlignment = UITextAlignmentCenter;
accompanyingLectureCell.detailTextLabel.textAlignment = UITextAlignmentCenter;
accompanyingLectureCell.textLabel.text = NSLocalizedString(@"New Accompanying Lecture", @"");
accompanyingLectureCell.detailTextLabel.text = NSLocalizedString(@"Lecturer, Time, Location, etc.", @"");
accompanyingLectureCell.accessoryType = UITableViewCellAcce开发者_JS百科ssoryDisclosureIndicator;
accompanyingLectureCell.frame = CGRectMake(0, 0, 320, 82);
// initialize datasource for all four sections
datasource = [[NSMutableArray alloc] initWithObjects:[NSMutableArray arrayWithObject:[lecturerCell autorelease]], [NSMutableArray arrayWithObject:[lectureDetailsCell autorelease]], [NSMutableArray arrayWithObject:[timeAndLocationCell autorelease]], [NSMutableArray arrayWithObject:[accompanyingLectureCell autorelease]], nil];
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
return [[datasource objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
CGRect currentFrame = [[[datasource objectAtIndex: indexPath.section] objectAtIndex:indexPath.row] frame];
return currentFrame.size.height;
}
What happens if you simply return 82 in the heightForRowAtIndexPath method and don't set the cell's frame in viewDidLoad?
精彩评论