Duck
Duck

Reputation: 35993

iphone - cached UIViewControllers?

I have to present 4 view controllers in sequence. One is the continuation of the other. They are presented by a navigationController.

A > B > C > D

if I go to A, then to B, then to C and go back to B, when I return to C it appears faster the second time. I suppose all C are being cached or stored somehow. The problem with this is that, for example, C calls a UIImagePickerController the first time it enters but not the second one. Why?

The UIImagePickerController is presented inside C's viewDidLoad, by a line like

[self.navigationController presentModalViewController:picker animated:YES];

but obviously, if C is being "cached" viewDidLoad will not run the second time, and this is why the picker is not being called, except for the first time.

I like the idea of a cached VC, because it is fast as hell to go back and forward, but, where should I put the call to the picker, so it is called correctly? I thought it would be viewWillAppear, but I tried that and this method is never called.

any ideas? thanks

Upvotes: 0

Views: 103

Answers (2)

gavrix
gavrix

Reputation: 321

There is no such caching that will omit calling of viewDidLoad. You can always put breakpoint there and see if it gets ever called or not.

Upvotes: 1

Rob Napier
Rob Napier

Reputation: 299455

Double-check viewDidAppear:. This is the correct place for the code you're describing. If it's not being called, that suggests you're doing something else incorrectly, or that you're using the wrong signature for the method.

Upvotes: 1

Related Questions