views:

1134

answers:

1

Hi guys!

I have a problem and I will try to explain the issue:

  • I have one main UIViewController (Whole screen)
  • I have one secondary UIViewController (setbounds)
  • I added my secondary view to my mainview using this:

    [mainController.view addSubview:secondaryController.view];

  • I created a third controller: modalController, i added it to my secondary controller like this:

    [secondaryController presentModalViewController:modalController animated:YES];

  • I make calculus based on some events inside of my modelController.

  • Im able to send messages from my modalController to my secondaryController using:

[[self parentViewController] performSelector:@selector(myMethodInSecondaryController:) withObject:myObject afterDelay:.5];

NOTE: "self" corresponds to the modalController
  • I need to pass "myObject" to my mainController, but i cant make reference to my mainController from the secondaryController. I tried this:

[[self parentViewController] performSelector:@selector(myMethodInMainController:) withObject:myObject afterDelay:.5];

NOTE: "self" corresponds to the secondaryController

but it doesn't work, i have access to my mainController's view using:

self.view.supperview

NOTE: "self" is my secondaryController

but no to it's controller.

Thanks in advantage for your help. Alejandra :)

+3  A: 

In your secondary controller, try

id mainViewController = [self.view.superview nextResponder];

and see if this is the main view controller you're looking for.

Nikolai Ruhe
Thanks Nikolai !!!!!!!!!!!!!!!!!That worked perfectly :)thanks Regards from Guadalajara Mexico!!Alejandra :)
Alejandra
You are welcome (from Berlin, Germany)
Nikolai Ruhe