1

Ok here is the code that I wrote to display the UIImagePickerController in the camera source. I just declared the myPhotopicker in the header for the property and retain it. Synthesized it in the main code file. Then calling the picker 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];
}

Upon calling it, there are a few things that is weird happening to the app.

  1. Sometimes, when there are many apps running in the background (iPhone4), the app would fail to load the camera and crash the app. Though it will load CameraRoll/PhotoAlbums without problem.

  2. If the camera view is able to load (when there are less apps running in the background), tapping the Cancel button on the camera view results in the app rebooting itself (where the Default.png image is shown quickly, and back to the main page - like when we started the app).

I have been trying to figure out this problem, but not sure what to do... pls help.. Thanks.

GeneCode
  • 7,545
  • 8
  • 50
  • 85
  • I have faced same problem and didn't get any feasible solutions for that. Please refer my Question: http://stackoverflow.com/questions/4806547/application-get-crashed-when-taken-the-picture-in-iphone-4g. Thanks. – Pugalmuni Mar 15 '11 at 08:45
  • @Pugal Devan, thanks for your comment, but my case is a bit different. It crashed just before the camera shutter opens up. Not after taking a photo. If the camera shows up I will be able to take photo and so on without any problems. – GeneCode Mar 15 '11 at 08:52
  • Do you think you could make your code example conform to standard indentation style (any standard at all is fine)? Right now, it's incredibly hard to read. – Jonathan Sterling Mar 15 '11 at 17:58
  • @Jonathan, yup sure. Sorry about that. I made it nice already. – GeneCode Mar 16 '11 at 17:02
  • No problemo, looks much better now! :) – Jonathan Sterling Mar 16 '11 at 21:59

2 Answers2

1

here is the complete code of image pickercontrol try too find solu. here.

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

Regards,

Shyam Parmar

GameLoading
  • 6,688
  • 2
  • 33
  • 57
1

Rather than 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];
}

You should also implement the delegate to remove the modal view controller from view when it is dismissed (if you haven't already).

You should also check that the current class conforms to the UINavigationConrollerDelegate protocol.

gnuchu
  • 1,496
  • 13
  • 21
  • No this doesn't help. I tried your suggestion, but the app still gets rebooted when I press Cancel button on the camera view. – GeneCode Mar 16 '11 at 17:03