2

Can anybody think of why this line of code [self.view insertSubview:dataInputController.view atIndex:0]; would generate two viewDidLoad messages to the dataInputViewController followed by one viewWillDisappear and one dealloc?

I expected a single viewDidLoad with no viewDidDisappear or dealloc.

user990380
  • 21
  • 2

1 Answers1

0

Is it possible that dataInputController.view already had a superview? That would explain all calls.

ott--
  • 5,642
  • 4
  • 24
  • 27
  • I looked at _parentViewController for the dataInputController and it is nil both times viewDidLoad was called. I did notice that the call stack is not what I expected. The first time viewDidLoad is called the stack looks like this-- main, UIApplicationMain, UINibInstantiateWithOwner, switchViewController, UIViewController, UINibInstantiateWithOwner, dataInputViewController. The second time viewDidLoad is called the stack looks like this--main, UIApplicationMain, UINibInstantiateWithOwner, switchViewController, UIViewController, dataInputViewController. No 2nd UINib in the stack! – user990380 Oct 28 '11 at 22:07
  • Check `[dataInputController.view superview]` just before doing the insert. – ott-- Oct 29 '11 at 00:31