How to insert / hide / show a row in a static UITableView?

I have UITableViewwith static cells created in a storyboard. When the user touches a cell, another cell should hide / show. This is similar to what it looks like in the built-in calendar application in iOS 7. This is basically the same question as this one: How do I implement a view that appears as a date picker in calendar? , but I have a static table view, not a dynamic one, otherwise the solution would work. If I try it, the exception will close.

As now, I can show and hide the cell in the row, but it is without animation, which is unacceptable. This is the code I'm using:

- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 2 && indexPath.row == 0)
    {
        NSIndexPath *dateIndexPath = [NSIndexPath indexPathForRow:1
                                                        inSection:2];

        UITableViewCell *dateCell = [self.tableView cellForRowAtIndexPath:dateIndexPath];

        if (dateCell.hidden)
        {
            dateCell.hidden = NO;
        }
        else
        {
            dateCell.hidden = YES;
        }
    }
}
+4
1

hye, , , ,

UITableView . ?

+3

Source: https://habr.com/ru/post/1541317/


All Articles