0

I have 2 view (view A and view B).

In viewA when I touch a button I execute this code to flip a viewB:

viewB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewB animated:YES];

And now when I came back to viewA I use this code:

[self dismissModalViewControllerAnimated: YES]; //here is my problem

I need to set same parameters to viewA when I execute dismiss. How can I do it?

EDIT I have not found any solution and I used a pushNavigation in this way:

FirstViewController *viewA = [self.storyboard instantiateViewControllerWithIdentifier:@"myView"];

// Effettuo il push alla view successiva
[self.navigationController pushViewController:viewA animated:YES];
Dany
  • 2,290
  • 8
  • 35
  • 56
  • I am not quite following what you are saying. What parameters are you trying to set on viewA? Are you trying to present viewA modally from viewB as well? – Joe Dec 22 '10 at 20:33
  • probabily I have same mistake, but my obiective is to push to the viewB when I touch inside a button in viewA. Now in this view(viewB) I set same parameter and when I touch inside a button in viewB I came back to viewA passing same parameter. How can I do it? – Dany Dec 22 '10 at 21:18

2 Answers2

0

search for a delegate example or simply use NSNotificationCenter to send a message from one view to another

ClassA:

@protocol myDelegate

@interface ClassA : UIViewController {

}

@end

@protocol myDelegate
- (void)thingsDone:(id)someValues;
@end

ClassB:

#import "ClassA.h"
@interface ClassB : UIViewController <myDelegate> {

}
@end
0

You have two options:

1- You can use the delegate pattern and register viewA as the delegate object:

viewB.delegate = self;
[self presentModalViewController:viewB animated:YES];

And in viewB you can send messages to the delegate:

[delegate someMethod];

2- You can keep a pointer to viewA in viewB:

viewB.viewA = self;
[self presentModalViewController:viewB animated:YES];

And then you can send messages to the viewA directly:

[viewA someMethod];
Community
  • 1
  • 1
Hejazi
  • 16,587
  • 9
  • 52
  • 67
  • why when I try to use viewB.delegate = self the method delegate don't exist for the viewB? – Dany Dec 22 '10 at 23:05
  • Refer to this question to know how you can make and use delegates: http://stackoverflow.com/questions/626898/how-do-i-create-delegates-in-objective-c – Hejazi Dec 23 '10 at 15:14