I am trying to have a number (UILabel) to be send to another UIViewController.
Now I am able to go one way, but I also need to bring the result back to the initial Controller when I return to that.
On top of that I am trying to do this with 4 UILabel's so I need to distinguish between them.
Now to get to the 2nd ViewController I want to use a segue like this:
if ([segue.identifier isEqualToString:@"ChangeNumberSegue"])
{
NSLog(@"Changing the Number on NumberPadViewController");
NumberPadViewController *numberPad = segue.destinationViewController;
if(_BtnNumber01)
{
numberPad.numberLine.text = _LblNumber01.text;
}
if(_BtnNumber02)
{
numberPad.numberLine.text = _LblNumber02.text;
}
if(_BtnNumber03)
{
numberPad.numberLine.text = _LblNumber03.text;
}
if(_BtnNumber04)
{
numberPad.numberLine.text = _LblNumber04.text;
}
}
The question is: What is the correct way to dismiss the 2nd view once I am done with it. Once I am in the second view it will only change the number of the selected label.
Cheers.
Assuming this is a modal segue...
In lieu of an actual return value, just create a property in the first view controller that you want set, such as:
@property (nonatomic, assign) NSInteger theValue;
Inside the second view controller, you can get a handle to the first such as:
FirstViewController *vc = (FirstViewController *) [self presentingViewController];
vc.theValue = 5;
As far as returning back to the original view controller, you can add this inside your second view controller:
[self dismissViewControllerAnimated:YES completion:nil]; // iOS 6
// or
[self dismissModalViewControllerAnimated:YES]; // iOS 5 or earlier