IOS - Affordable Modal Parental Property

I probably come across this too often, but is there a way to access the modal parent property?

So, I call "presentModalViewController" and then I can access some properties on the view controller that just called it from the modal.

Thanks Ashley

+3
source share
3 answers

if you are using iOS 5, you can call self.presentingViewController to access the parent view controller

here is the link to the apple

+4
source

- presentingViewController, parentViewController, ( , , ), .

, - , presentingViewController.

+2

, , , , , , .

:

((pController *)self.parentViewController).testString;

, UIViewController, , UITabBarController, selectedViewController .

modal.h

id delegate;

@property (nonatomic, assign) id delegate;

alloc/init modalViewController,

modalViewController.delegate = self;

That way I could call self.delegate from my modal. This was not enough, since it does not say which view controller it is, so I can’t say

self.delegate.testString;

But the casting, which I learned earlier, allowed me to get a fully working solution

((pController *)self.delegate).testString;

Hopefully I didn’t just blabber along this path, and I hope that this can help someone in the future.

+1
source

All Articles