Развертывание и свертывание ячеек табличного представления в ios
У меня есть табличное представление настраиваемых ячеек и несколько кнопок в каждой ячейке. Нажатие на любую из кнопок внутри ячейки откроет другое настраиваемое представление ниже этой ячейки. Следующее нажатие на ту же кнопку свернет представление и понадобится одинаково для всех ячеек. Я пытался использовать метод insertrow при нажатии кнопки, но напрасно. Как я могу это сделать, используя только делегатов табличного представления.
Вот что я попробовал:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"CustomCell_For_Dashboard";
CustomCellFor_Dashboard *customCell = (CustomCellFor_Dashboard *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (customCell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellFor_Dashboard" owner:self options:nil];
customCell = [nib objectAtIndex:0];
}
[customCell.howyoulfeelBtn addTarget:self action:@selector(buttonclicked:) forControlEvents:UIControlEventTouchUpInside];
customCell.nameLabel.text = @"test";
customCell.imgView.image = [UIImage imageNamed:@"Default.png"];
// customCell.prepTimeLabel.text = [prepTime objectAtIndex:indexPath.row];
return customCell;
}
-(void)buttonclicked:(id)sender{
NSIndexPath *indexPath = [myTable indexPathForCell:sender];
[myTable beginUpdates];
NSIndexPath *insertPath = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
[myTable insertRowsAtIndexPaths:[NSArray arrayWithObject:insertPath] withRowAnimation:UITableViewRowAnimationTop];
}
Может кто-нибудь помочь мне?