相关疑难解决方法(0)

dismissModalViewController并传回数据

我有两个视图控制器,firstViewControllersecondViewController.我正在使用此代码切换到我的secondViewController(我也传递一个字符串):

secondViewController *second = [[secondViewController alloc] initWithNibName:nil bundle:nil];

second.myString = @"This text is passed from firstViewController!";

second.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;

[self presentModalViewController:second animated:YES];

[second release];
Run Code Online (Sandbox Code Playgroud)

然后我在secondViewController中使用此代码切换回firstViewController:

[self dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

所有这一切都很好.我的问题是,如何将数据传递给firstViewController?我想从secondViewController传递一个不同的字符串到firstViewController.

iphone uiviewcontroller modalviewcontroller ios

84
推荐指数
2
解决办法
3万
查看次数