0

Please help, if you have any experience, our time is thicking.

I have this structure.

AppDelegate...
...Owns a _root ViewController (its view added to window)
...what owns the _main ViewController (its view added to _root's view)
...that has a Navigation controller (its view added to _main's view)
...then different viewControllers travels in this navigation stack.

But viewDidAppear/viewWillAppear methods don't get called in the innermost views. I don't know why.

As I read the documentation, it says "when added to a window". Are they works with windows? Don't think so. What should I do? Why don't these CRUTIAL methods get invoked?

Geri Borbás
  • 15,810
  • 18
  • 109
  • 172
  • Hope this helps http://stackoverflow.com/questions/3560669/viewwillappear-viewdidappear-not-being-called-not-firing – visakh7 Mar 21 '11 at 12:39

1 Answers1

1

Nesting view controllers is not allowed by the framework.

Yes, Apple does do it (for instance, by letting you embed one of your UIViewControllers in a tab/navigation view controller), but then they would be the ones to know how to do it.

It's still possible, by forwarding the right messages from your outer view controllers to your inner view controllers, but it takes a lot of care and is probably not very future-proof. It might save you this time, though! I.e. if you get a viewWillAppear in your _root, forward that to its sub-viewcontrollers, etc. If you manage to do this correctly for all appearances/disappearances, rotations, memory management then you're good.

Two years have passed and nesting view controllers is now supported: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6

Steven Kramer
  • 8,473
  • 2
  • 37
  • 43
  • I see. So my desktop viewController is misdesigned as well? It is a viewController that has many _thumbnailGroup viewControllers, that have many _thumbnailStack viewControllers having many small _thumbnail viewControllers. So all the inner objects should be simple UIView subclasses? – Geri Borbás Mar 21 '11 at 14:04
  • THANKS! I removed the _root viewController, all the logic went down to _main viewController so the subControllers' delegate methods now get called. – Geri Borbás Mar 21 '11 at 14:33
  • Yeah, UIViews inside a UIView managed by a view controlelr would do it usually. Unfortunately, sometimes you'll need a bit of both, and that's when the trouble starts. Good luck with your redesign. – Steven Kramer Mar 21 '11 at 15:34
  • This response is incorrect, as Apple has now blessed an API for adding "child view controllers". See: http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW6 – algal Feb 18 '13 at 12:59