有没有办法把数据从一个视图传递到modalviewcontroller



我有一个视图与一个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];
}   

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

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

最新更新