-1

I have a main view controller that processes data. I want to send this data and display it in a modal view without using another controller.

I have something like this in my controller:

NSString *myData = @"something";
[self performSegueWithIdentifier:@"MySegue" sender:myData];

I have created a new view in the storyboard and a "Present modally" segue between them. I have created a label in the new view that I would like to change to display the content of myData.

But since there is no controller for this view I can't find a way to link the label to the data. Every advice I find (like PrepareForSegue) is for a two controllers configuration.

kursus
  • 1,297
  • 1
  • 16
  • 31

1 Answers1

2

Every scene (at least every scene that you want to update custom controls on) should have its own view controller. If you create a scene without a custom view controller class specified, it will still instantiate a standard UIViewController object. Without a custom view controller, you have no way of updating the label on that destination scene.

The standard answer applies here. Give that destination scene its own view controller class, define a custom property in that destination class, have prepareForSegue in the source controller update that custom property in the destination controller, and have the destination view controller's viewDidLoad update the label on the basis of that custom property you set.

Community
  • 1
  • 1
Rob
  • 371,891
  • 67
  • 713
  • 902