Manish Agrawal
Manish Agrawal

Reputation: 11026

not call viewWillAppear while popping from view controller in iPhone

I am using iOS image gallery for selecting the image in my code
When I have done selecting image it calls the viewWillAppear method of my current class in which I have clear some variable.
So it clear the variable again which I not want.
Is there any method when the image gallery close it not calls the viewWillAppear method.
Thanks

Upvotes: 1

Views: 922

Answers (2)

YuAo
YuAo

Reputation: 1427

Simply no.

When you present the UIImagePickerController, it fill the full screen. And when it dissmis, the viewWillAppear or viewDidAppear will be called.

You can try to move the variables that you'd like to keep in viewDidLoad method, if it is possible.

Upvotes: 2

Rui Peres
Rui Peres

Reputation: 25907

The problem here is your architecture and not the way the UIView cycle works. Your question is a bit vague, so I don't fully understand the complexity of your application and so I can't provide a suitable solution to fix your problem.

Although for a quick fix, you can do something like this:

1) When you open your gallery, just set a BOOL to YES.

2) When you close your gallery and you enter in viewWillAppear, just check if the BOOL is YES, if YES, then do not clear your variables.

3) Don't forget to reset your BOOL value again to NO.

Upvotes: 4

Related Questions