Я добавляю развернутый / складываемый UIView ниже UITableviewCell. Я могу добавить и скрыть представление о действии кнопки, но не могу удалить его, когда представление отображается в другой ячейке. Я обновляю ограничение высоты вида на 0 при скрытии.
Вот мой код:
-(void)doneButtonClicked:(UIButton*)sender{
CGPoint buttonPosition = [sender convertPoint:CGPointZero
toView:_tableView];
NSIndexPath *indexPath = [_tableView
indexPathForRowAtPoint:buttonPosition];
CustomCell *cell = [_tableView cellForRowAtIndexPath:indexPath];
for (int i = 0; i < [_expandedIndexPaths count]; i++){
if (i != indexPath.row && [_expandedIndexPaths count] > 0){
[self.expandedIndexPaths removeObject:indexPath];
//Animation effect for expanding/collapsing view
[cell animateClosed];
}
}
if (sender.tag == 0) {
[self.expandedIndexPaths addObject:indexPath];
[cell animateOpen];
//[self.expandedIndexPaths removeObject:indexPath];
}else{
[self.expandedIndexPaths removeObject:indexPath];
[cell animateClosed];
}
[_tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}