谢谢您的帮助。我有一个使用以下代码扩展的自定义单元格。但是,第一个单元格(索引 0)总是在 ViewControllers 启动时展开?
我错过了什么?您如何让它们在启动时全部未扩展,仅在选择时扩展。
非常感谢。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCellCell *cell;
static NSString *cellID=@"myCustomCell";
cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil)
{
NSArray *test = [[NSBundle mainBundle]loadNibNamed:@"myCustomCell" owner:nil options:nil];
if([test count]>0)
{
for(id someObject in test)
{
if ([someObject isKindOfClass:[CustomCellCell class]]) {
cell=someObject;
break;
}
}
}
}
cell.LableCell.text = [testArray objectAtIndex:[indexPath row]];
NSLog( @"data testarray table %@", [testArray objectAtIndex:[indexPath row]]);
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedRow = indexPath.row;
CustomCellCell *cell = (CustomCellCell *)[tableView cellForRowAtIndexPath:indexPath];
[tableView beginUpdates];
[tableView endUpdates];
cell.buttonCell.hidden = NO;
cell.textLabel.hidden = NO;
cell.textfiledCell.hidden = NO;
cell.autoresizingMask = UIViewAutoresizingFlexibleHeight;
cell.clipsToBounds = YES;
cell.accessoryType = UITableViewCellAccessoryNone;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
if(selectedRow == indexPath.row) {
return 175;
}
return 44;
}