Parent view problems with UIImagePickerControllerSourceTypeCamera

I have a strange problem with UIImagePickerControllerSourceTypeCamera. My application makes it possible to select an image from the gallery or take a picture using the camera. If I choose a gallery, I will choose a photo and return to my view, no problem.

However, when using UIImagePickerControllerSourceTypeCamera, there seems to be something odd with my view when I return to it.

For example, I have a bunch of code in the viewDidLoad method that moves some objects in the view, if it should be based on some factors - this code is called when I exit UIImagePickerControllerSourceTypeCamera, but it is not called when I exit the gallery.

Is this expected?

+3
source share
1 answer

I think your presentation is reset by a topic didReceiveMemoryWarningthat is triggered by a resource-intensive camera. You can force the simulator to generate a memory warning without a camera to test this theory.

Generally speaking, viewDidLoad should be able to handle calls several times. This is not a method init. It is called again if self.viewset to nil and needs to be recreated later. It may be a more appropriate place to host any code that you have there, which causes problems, but the methods initare complicated because the designated initializer bypasses the nib load.

nib initWithCoder, init, , dearchiving . , , loadView, , , , . - initWithCoder, , args super, , , . , , , , , .

+3

Source: https://habr.com/ru/post/1729801/


All Articles