Question

I want to resize an UITableView contain in a UIViewController by pushing a button on an iPad application. The goal is to see an other UITableView in background. The button set a flag in the class and call a function to resize the table depending of the flag.

I have to click three times on the button to launch the resize of the table. The resize is working one time on two.

Can somebody help me?

This is my code:

- (void)displayTableView:(BOOL)animated
{
    CGFloat filterWidth = self.tableViewFilter.frame.size.width;
    CGFloat viewWidth = self.view.frame.size.width;

    CGFloat originx = self.showFilters == YES ? filterWidth : 0;
    CGFloat originy = 0;
    CGFloat width = self.showFilters == YES ? viewWidth - filterWidth : viewWidth;
    CGFloat height = self.view.frame.size.height;

    if (animated == YES) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
    }

    [self.tableView setFrame:CGRectMake(originx, originy, width, height)];

    if (animated == YES) {
        [UIView commitAnimations];
    }
}

Thank you for your help

No correct solution

OTHER TIPS

Try UIView animations like this.....

- (void)displayTableView:(BOOL)animated
{
    CGFloat filterWidth = self.tableViewFilter.frame.size.width;
    CGFloat viewWidth = self.view.frame.size.width;

    CGFloat originx = self.showFilters == YES ? filterWidth : 0;
    CGFloat originy = 0;
    CGFloat width = self.showFilters == YES ? viewWidth - filterWidth : viewWidth;
    CGFloat height = self.view.frame.size.height;

    if (animated == YES)
    {
         [UIView animateWithDuration:0.5 animations:^{
              [self.tableView setFrame:CGRectMake(originx, originy, width, height)];
         }];

    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top