1

I have tried UIImagePickerController in custom camera,when application going out or when i am going call the safari , that time camera shutter not open,i have used following code.

 -(IBAction)cameraAction:(id)sender
{

   NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
   [defaults setValue:@"rear" forKey:@"rearcamera"];
   [defaults synchronize];
   NSLog(@"hai App %@",[defaults valueForKey:@"closeApp"]);

   dispatch_async(dispatch_get_main_queue(), ^{
       [cameraBut setSelected:NO];
       self.picker = [[UIImagePickerController alloc] init];
       self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
       self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
       self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
       self.picker.showsCameraControls = NO;
       self.picker.navigationBarHidden = YES;
       self.picker.toolbarHidden = YES;
       self.picker.wantsFullScreenLayout = YES;



   });


}
C.M.Raj
  • 86
  • 12
  • "when application going out or when i am going call the safari , that time camera shutter not open," -- What you actually want to do, not getting your question? – Mrunal Mar 14 '13 at 16:01
  • I need open the camera shutter again application run time . – C.M.Raj Mar 15 '13 at 04:27

2 Answers2

1

Don't Declare the picker in .h file. Simple Declare and Use in Button Action and Release after work will finish.

-(IBAction)cameraAction:(id)sender
{

   NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
   [defaults setValue:@"rear" forKey:@"rearcamera"];
   [defaults synchronize];
   NSLog(@"hai App %@",[defaults valueForKey:@"closeApp"]);

   dispatch_async(dispatch_get_main_queue(), ^{
       [cameraBut setSelected:NO];
      UIImagePickerController *picker = [[UIImagePickerController alloc] init];
      picker.sourceType = UIImagePickerControllerSourceTypeCamera;
      picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
      picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
      picker.showsCameraControls = NO;
      picker.navigationBarHidden = YES;
      picker.toolbarHidden = YES;
      picker.wantsFullScreenLayout = YES;

      [self presentViewController:picker animated:YES completion:nil];

   });


}
Siba Prasad Hota
  • 4,779
  • 1
  • 20
  • 40
  • Hi @Siba prasad Hota i have tried but not working.What i worng with my codes i don't know.Then how to calculate camera taken images ratio.and upload to server then display same camera taken image resolution. – C.M.Raj Mar 25 '13 at 14:46
0

As per your explanation, I guess you require to open camera shutter only and your camera is working perfectly.

So I would suggest you to add one animation, which will simulate camera shutter opening.

Here is the code for that, this one is Core Animation for CALayer:

CATransition *shutterAnimation = [CATransition animation];
     [shutterAnimation setDelegate:self];
     [shutterAnimation setDuration:0.6];

     shutterAnimation.timingFunction = UIViewAnimationCurveEaseInOut;
     [shutterAnimation setType:@"cameraIris"];
     [shutterAnimation setValue:@"cameraIris" forKey:@"cameraIris"];
     CALayer *cameraShutter = [[CALayer alloc]init];
     [cameraShutter setBounds:CGRectMake(0.0, 0.0, 320.0, 425.0)];
     [self.layer addSublayer:cameraShutter];
     [self.layer addAnimation:shutterAnimation forKey:@"cameraIris"];

This is not the exact solution, but this is one of the way around.

Hope this will help you to achieve your requirement.

Mrunal
  • 13,982
  • 6
  • 52
  • 96
  • Hi ,This the problem.custom camera working fine but when I share the image using in google+ that time application is background (i mean minimize)then reopen the app that time shutter not open (i mean shuck).how can avoid the shutter shuck problem.see this link http://stackoverflow.com/questions/8058998/iphone-camera-iris-shutter-stuck-in-closed-position?rq=1 – C.M.Raj Mar 15 '13 at 07:18