not call viewWillAppear while popping from view controller in iPhone

929 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

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.