开发者

Is there a way to pass data from one view to modalviewcontroller

开发者 https://www.devze.com 2023-03-29 00:40 出处:网络
I have a view with a UIView and a button. Pressing the button brings up a ModalViewController which is UIView with UITextField in it. I need to pass the string value of NSObject in the UIView to the M

I have a view with a UIView and a button. Pressing the button brings up a ModalViewController which is UIView with UITextField in it. I need to pass the string value of NSObject in the UIView to the ModalViewController as a string. On button click I call this:

-(void) editNote{

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

[self.navigationController presentModalViewController:nav animated:YES];
[vc release];
}   

Normally, on row select we push the data using pushviewcontro开发者_如何学JAVAller to the next view but after doing lot of google I cannot figure out how to pass the data using presentmodalviewcontroller.


You could add a property to TextViewController, then just use vc.object = myObject. Or you could make a new init method that takes some more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消