I am trying to pass some data between my first and second ViewController
. I already instantiated the second view controller like this:
RegistrationViewController registration = new RegistrationViewController();
I set the value of the textfield to the variable email from the registration class like this:
registration.email = txtEmail.Text;
this.NavigationController.PushViewController(registration, true);
Then in the second ViewController
I use it like this:
public string email { get; set; }
txtEmail.Text = email ;
Sadly, I don't have a value in the email variable. How can I achieve successfully passing the data to the new ViewController
.
Code for changing the controller:
registration.email = txtEmail.Text;
string password = txtPassword.Text;
RegistrationViewController controller = this.Storyboard.InstantiateViewController("RegistrationViewController") as RegistrationViewController;
this.NavigationController.PushViewController(registration, true);
this.NavigationController.PushViewController(controller, true);
Try something based on this :
SecondViewController controller = this.Storyboard.InstantiateViewController("SecondViewController") as SecondViewController;
//Here you pass the data from the registerViewController to the secondViewController
controller.email = registration.email;
this.NavigationController.PushViewController(registration, true);
Hope it helps
try this out
UIStoryboard board = UIStoryboard.FromName("Main", null);
UIViewController ctrl = (UIViewController)board.InstantiateViewController("RegistrationViewController");
ctrl.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
this.PresentViewController(ctrl, true, null);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.