0

現在のView Controllerから、viewControllerをモデルとして提示して、ユーザーから大きなテキスト入力を取得しています。私はこれを行うことができますが、入力されたテキストを呼び出されたView Controllerに戻す方法がわかりません。

誰かが見てコメントできますか?

NotesController *vcNotes =  [self.storyboard instantiateViewControllerWithIdentifier:@"FullNotes"];
[self presentViewController:vcNotes animated:YES completion:nil];
4

1 に答える 1

1

委任委任プロトコルを定義し、delegateプロパティを に追加する必要がありますNotesController

プロトコルには、次のようなメソッドが必要です。

- (void)notesController:(NotesController*)nc didFinishWithText:(NSString*)text;

あなたのNotesController

@property (nonatomic, weak) id<NotesControllerDelegate> delegate;

ここで、プレゼンテーションの前に、デリゲートをプレゼンテーション ビュー コントローラーに設定します。

NotesController *vcNotes =  [self.storyboard instantiateViewControllerWithIdentifier:@"FullNotes"];
vcNotes.delegate = self;
[self presentViewController:vcNotes animated:YES completion:nil];

ここで、メモ コントローラーで、準備ができたらデリゲート メソッドを呼び出します。

[self.delegate notesController:self didFinishWithText:self.text];

于 2014-03-14T23:07:45.800 に答える