1

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

Manish Agrawal
  • 10,958
  • 6
  • 44
  • 76

2 Answers2

4

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.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137
2

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.

DShah
  • 9,768
  • 11
  • 71
  • 127
YuAo
  • 1,427
  • 1
  • 10
  • 17