I think your view is getting dumped by the didReceiveMemoryWarning
thing which is being triggered by the resource-intensive camera stuff. You can force the simulator to generate a memory warning without the camera to test this theory.
Generally speaking, viewDidLoad needs to be able to deal with getting called multiple times. It's not an init
method. It gets called again if self.view
gets set to nil and the view later needs to be recreated. There may be a more appropriate place to put any code you have there that's causing problems, but the init
methods are tricky because the designated initializer is bypassed by nib loading.
When loaded from a nib, the class's initWithCoder
is called instead which bypasses the whole init process because dearchiving is assumed to be sucking in an already-initialized object. Therefore reinitializing the object might break stuff, like call loadView which essentially conflicts with what a nib contains as it's supposed to programmatically construct what the nib already has in it. You can still override initWithCoder as usual though as long as you pass through the args to super
like you should, but then this will not get called if you initialize the object with the designated initializer. Of course if you need to worry about that you can put all the code you want executed in both into a method that gets called from both overridden methods.