Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

viewWillAppear Event #5

Open
cSilas opened this issue Sep 7, 2013 · 4 comments
Open

viewWillAppear Event #5

cSilas opened this issue Sep 7, 2013 · 4 comments

Comments

@cSilas
Copy link

cSilas commented Sep 7, 2013

Hello,

In first you project is very cool! Nice Job!

I have a question. How can i detect the viewWillAppear method for each ViewController ? I need to catch the event.

Your project is not update for the iOS 7 ?

Thank you.
Regards.

@CrescentFresh
Copy link

DAPagesContainer's mechanism of adding a child view controller does cause viewWillAppear to not get called on the child view controller.

I've investigated the cause of this (iOS 6) and it appears to be in setViewControllers whereby it calls

[viewController willMoveToParentViewController:self];

Whereas according to apple's documentation it should be:

[self addChildViewController:viewController];

(which incidentally automatically calls willMoveToParentViewController).

When I changed the above line, the viewWillAppear method of my child view controllers does get called.

@cSilas
Copy link
Author

cSilas commented Sep 12, 2013

Thank you for your answer!
But i'm trying to modify my code with your help but it's the same. All the viewWillAppear, viewDidAppear, etc.. methods are called when the differents views are instantiates!
But when i navigate between the differents ViewControllers, the methods are never call! Do you know how can i resolved it ?

@CrescentFresh
Copy link

Oh that's by design (with the way DAPagesContainer is currently implemented). All your viewControllers are presented at the same time (inside a UIScrollView), the trick being the non visible ones are outside of the scrollView's visible area. But as far as the UIViewController life cycle, they have "appeared".

It isn't a problem is it? For the most part it works. Where it might get tricky is if you are waiting to do something (eg load dynamic content) until the very moment the view controller is slid into view. In such a case DAPagesContainer might not be the most appropriate tool for the job? Not sure...

@tunbeo
Copy link

tunbeo commented Feb 13, 2014

Add your child Controllers directly in DAPagesContainer in ViewDidLoad.
self.viewControllers = @[vc1, vc2];
[self addChildViewController:vc1];
[self addChildViewController:vc2];

and dynamic UIViewControllers works. (then you don't need DAViewController anymore)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants