i want send data view controller (left) from PopOverController (Right), how can I do it?
Asked
Active
Viewed 216 times
0
-
you need to use http://stackoverflow.com/questions/7864371/how-to-pass-prepareforsegue-an-object. – Mohammad Zaid Pathan Oct 25 '16 at 11:35
-
But i want to back in data (left) not send to popoverController. popoverController to send View Controller, i use [self dismissViewControllerAnimated:YES completion:nil]; – Mr Online Oct 25 '16 at 11:41
-
ok then you need to use custom delegates. – Mohammad Zaid Pathan Oct 25 '16 at 11:47
-
Most probably `dismissViewControllerAnimated` used when you navigate your app using `presentViewCont` method now here you need to use `popViewControllerAnimated` method in this case, there are certain no of methods to navigate app to diff VC. – vaibhav Oct 25 '16 at 12:35
2 Answers
0
You can pass data in prepareForSegue method, but first add identifier for segue. And use this code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"showPopover"]) {
NSLog(@"FirstViewController: prepareForSegue");
PopOverController * popoverVC = segue.destinationViewController;
popoverVC.myProperty = @"Data to be passed";
}
}

Ali Omari
- 371
- 3
- 11
-
i use [self dismissViewControllerAnimated:YES completion:nil]; because of that prepareForSegue not working – Mr Online Oct 25 '16 at 11:42
-
where you use [self dismissViewControllerAnimated:YES completion:nil]; ? – Ali Omari Oct 25 '16 at 11:46
-
prepareForSegue method called when ever you press the button in your case. can you please show me your code ? – Ali Omari Oct 25 '16 at 11:47
-
it's okay to use dismiss method in that view controller, but if you are doing that in correct way then prepareForSegue must called. – Ali Omari Oct 25 '16 at 11:49
0
First make one property which you get data of another viewcontroller .
In you case assume we want String data to first viewController so we make one property in second means PopOverController
@property (nonatomic, strong) NSString *recipeName;
After call prepare for segue method in first viewController in your case ViewController
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"IdentifierOfPushViewController"]) {
RecipeDetailViewController *destViewController = segue.destinationViewController;
destViewController.recipeName = @"Hello this passing data"
}
}

Mohit
- 126
- 2
- 10