0

I have UISplitViewController, that displays a UITableView in the master view, and also in the detail view.

When the user selects an item in the master view table, I reload the table in the detail view, and I would like to animate this with a page curl up.

Here's the code I'm using:

UITableView *newTableView = [[UITableView alloc] initWithFrame:self.tableView.frame style:UITableViewStylePlain];

[newTableView reloadData]; // ineffective attempt to load data prior to transition

[UIView transitionFromView:self.tableView
            toView:newTableView
            duration:0.8
            options:UIViewAnimationOptionTransitionCurlUp
            completion:^(BOOL finished)
                {
                    [newTableView reloadData]; // needed
                    [self setTableView:newTableView];
                    [newTableView release];
                }];

The transition occurs, but the 'revealed' UITableView is just a plain unpopulated UITableView, unless I force a reload of the data in the completion block. Then, if I do that, I get the transition to an empty table, followed by a reload to show the intended data - not very nice.

How can I make it so that the table that is revealed already shows the required data? Thanks.

Snips
  • 6,575
  • 7
  • 40
  • 64

1 Answers1

0

i guess this should work.

UITableView *newTableView = [[UITableView alloc] initWithFrame:self.tableView.frame style:UITableViewStylePlain];

[self setTableView:newTableView]; //until the table is set, there is no use reloading it
[newTableView reloadData]; // it should reload now and then animate

[UIView transitionFromView:self.tableView
            toView:newTableView
            duration:0.8
            options:UIViewAnimationOptionTransitionCurlUp
            completion:^(BOOL finished)
                {
                    [newTableView reloadData]; // needed
                    [self setTableView:newTableView];
                    [newTableView release];
                }];

u were missing [self setTableView:newTableView]; above reloadData. hope it helps. happy coding :)

Anshuk Garg
  • 1,540
  • 12
  • 14
  • Thanks for the response, but nope, that's not it. If I set tableView to newTableView beforehand, then it will reload the visible table before the animation (defeating the intend), and als I'm effectively asking for a transition from newTable to newTable. In practice, with your suggested change, the curl animate to a black view, not even an empty table. Thanks again anyway. – Snips Sep 10 '12 at 13:23