感谢您的帮助。 我有一个自定义单元格,使用下面的代码进行展开。但是,第一个单元格(索引0)总是在ViewControllers启动时扩展?iOS自定义单元格可扩展 - 索引0问题
我错过了什么?你如何在启动时将它们全部展开并仅在选择时展开。
很多谢谢。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCellCell *cell;
static NSString *[email protected]"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;
}
我觉得自己像一个ideeoat ....感谢您的帮助。 – AhabLives
@AhabLives,不是问题。通常人们往往会错过这一点。请接受,如果这有帮助。 :) – iDev
我试过......告诉我等10分钟.....所以我等着......再看看 – AhabLives