UIImagePickerController camera source problem

Well here is the code I wrote to display the UIImagePickerController in the camera source. I just declared myPhotopicker in the header for the property and saved it. Synthesize it in the main code file. Then, having typed the collector, I wrote the code below:

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
        if (myPhotopicker==nil) { 
            myPhotopicker = [[UIImagePickerController alloc] init];
            myPhotopicker.delegate = self; 
        }// create once!

        myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [self presentModalViewController:myPhotopicker animated:NO];
}

After calling it, there are several things that strangely happen to the application.

  • Sometimes, when many applications are running in the background (iPhone4), the application will not be able to load the camera and disable the application. Although it will load CameraRoll / PhotoAlbums without any problems.

  • If the camera image can load (when fewer applications are running in the background), clicking the โ€œCancelโ€ button on the camera screen will load the application (where the Default.png image is displayed quickly and back to the main page - for example, when we launched the application).

I tried to find out this problem, but not sure what to do ... pls help .. Thanks.

+1
source share
2 answers

here is the complete image selection management code, try to find a sola. here.

http://www.icodeblog.com/2009/07/28/getting-images-from-the-iphone-photo-library-or-camera-using-uiimagepickercontroller/

Hi,

Syam Parmar

+1
source

Instead of your โ€œcreate onceโ€ logic, try creating and releasing each time.

if ([UIImagePickerController  isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
     myPhotopicker = [[UIImagePickerController alloc] init];
     myPhotopicker.delegate = self;
     myPhotopicker.sourceType = UIImagePickerControllerSourceTypeCamera;
     [self presentModalViewController:myPhotopicker animated:NO];
     [myPhotopicker release];
}

, , ( ).

, UINavigationConrollerDelegate.

+1

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


All Articles