使用presentViewController:animated:completion时如何将数据传递给呈现的View Controller

时间:2013-10-18 02:49:36

标签: objective-c uiviewcontroller

使用presentViewController时:animated:completion方法如何将数据传递给呈现的View Controller?

1 个答案:

答案 0 :(得分:0)

您应该在呈现的视图控制器界面中公开属性,并从呈现视图控制器中设置它们。

PresentedViewController* presented = [PresentedViewController new];
presented.stringProperty = @"Hello world!"

[self presentViewController:presented animated:YES completion:^ {
    presented.anotherStringProperty = @"Hello again, world!"; //Set here if you need to pass the value after presentation.
}];