7

プロジェクトの 1 つで絵コンテを試しているときに、適切な解決策がないものに出会いました。

UITableViewController を表示するナビゲーション ベースのアプリケーションがあります。tableView には、ユーザーが作成した要素が取り込まれます。要素セルをタップすると、詳細ビ​​ュー コントローラーが表示されます。ユーザーは、tableView のボタンをタップして新しい要素を作成できます。これにより、作成を処理するモーダル ビューが表示されます。

ここで、ユーザーが要素の作成を完了してモーダル ビュー コントローラーを閉じると、テーブルビューではなく、対応する新しい詳細ビュー コントローラーが表示されます。しかし、ストーリーボードでこれを達成する方法がわかりません。

誰かがこれに適したパターンを持っていますか?

現在の状況

TableView --(tap create)--> creation modal view --(finish creating)--> TableView

する必要があります

TableView --(tap create)--> creation modal view --(finish creating)--> detail view
4

2 に答える 2

0

The best pattern I could come up with, is the same as the old pattern in code.

Add a property (nonatomic, weak) UINavigationController *sourceNavigationController to the modal view controller. When it becomes time to dismiss the modal view controller, add the following code:

DetailViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"];
detailViewController.element = newlyCreatedElement;
[[self sourceNavigationController] pushViewController:detailViewController animated:NO];

And to make sure the sourceNavigationController get set properly, add the following code in the prepareForSegue: of the TableView:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"newElementSegue"]) {
        [[segue destinationViewController] setSourceNavigationController:self.navigationController];
    }
}
于 2013-05-05T11:04:43.937 に答える