How to transfer data from PerformSegue in a single point

I have a class of the source of the table and in the line click I call the function below to go to another controller, but I want to transfer some data.

controller.PerformSegue("backtorootviewsague",controller); 

Does anyone know how I can achieve this. I am new to monotouch and ios. I can’t figure out how to achieve this.

+4
source share
1 answer

PrepareForSegue is the right place for this. For example, if the controller that creates the CustomerViewController is called CustomerListViewController , it overrides this method in CustomerListViewController as follows:

 public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender) { base.PrepareForSegue (segue, sender); // do first a control on the Identifier for your segue if (segue.Identifier.Equals("your_identifier")) { var viewController = (CustomerViewController)segue.DestinationViewController; viewController.MyData = dataToInject; } } 

where CustomerViewController has a public property similar to the following:

 public SomeTypeData MyData { get; set; } 

You can see this in action in Xamarin samples .

Hope this helps.

+10
source

Source: https://habr.com/ru/post/1432984/


All Articles