0

UISplitViewControllerがあり、マスタービューと詳細ビューにUITableViewを表示します。

ユーザーがマスタービューテーブルでアイテムを選択すると、詳細ビ​​ューでテーブルをリロードします。これをページを丸くしてアニメーション化します。

これが私が使用しているコードです:

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];
                }];

遷移は発生しますが、完了ブロックでデータのリロードを強制しない限り、「明らかにされた」UITableViewは単純な未入力のUITableViewです。次に、それを行うと、空のテーブルに遷移し、目的のデータを表示するためにリロードが続きます-あまり良くありません。

表示されるテーブルに必要なデータがすでに表示されるようにするにはどうすればよいですか?ありがとう。

4

1 に答える 1

0

これはうまくいくはずです。

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];
                }];

あなたは[self setTableView:newTableView];上にありませんでしたreloadData。それが役に立てば幸い。幸せなコーディング:)

于 2012-09-10T13:08:25.463 に答える