有没有办法将数据从一个视图传递给modalviewcontroller

lif*_*son 0 iphone objective-c uiview presentmodalviewcontroller

我有一个UIView和一个按钮的视图.按下按钮会弹出一个ModalViewController,它是带有UITextField的UIView.我需要将UIView中的NSObject的字符串值作为字符串传递给ModalViewController.点击按钮我称之为:

-(void) editNote{

TextViewController * vc = [(TextViewController *)[TextViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];

[self.navigationController presentModalViewController:nav animated:YES];
[vc release];
}   
Run Code Online (Sandbox Code Playgroud)

通常,在行选择时我们使用pushviewcontroller将数据推送到下一个视图,但是在做了很多谷歌后我无法弄清楚如何使用presentmodalviewcontroller传递数据.

jtb*_*des 5

您可以向TextViewController添加属性,然后使用vc.object = myObject.或者您可以创建一个init获取更多信息的新方法.