1

Target: Taking pictures in silent mode while other GUI is running.

OS: IOS 4.3

I doing a test, I want to take one image in silent mode when ViewDidLoad is execute: I do not want any camera gui what so ever... let me know what do you think..

Observing the UIImagePickerController I see that I can assign few properties and execute takePicture method.. the bottom line is that nothing happened when try to execute it, I saw few KBs.. that tells that you have to wait.. so I did put sleep(10) but it did not help.

Maybe I missing delegate somewhere, while I read delegate is not a must.. Thoughts?

Here is the code:

Header file:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

@interface VisionViewController : UIViewController
{

    UIImagePickerController *controller;

}

-(void)settingControllerAndTakingPicture;


@end

and Implementation file

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad];

//Taking an Image

[self settingControllerAndTakingPicture ];

}

-(void)settingControllerAndTakingPicture

{
    controller = [[UIImagePickerController alloc] init];
    //Setting the control source type as the Camera device.
    controller.sourceType = UIImagePickerControllerSourceTypeCamera;

    //Camera display is off, the player will not see it during games.
    controller.showsCameraControls = NO;

    //Picking only the front camera.
    controller.cameraDevice = UIImagePickerControllerCameraDeviceFront;

    //Turning the camera flash off.
    controller.cameraFlashMode = UIImagePickerControllerCameraFlashModeOn;


    //Setting the controller view as self view
    controller.view = self.view;   

    //Taking a picture         
    [controller takePicture]; 


}

Again I am only interesting in silent mode.

1 Answers1

0

You haven't added the UIImagePickerController to your view hierarchy, it won't instantiate until you do. You need presentModalViewController or similar.

Also I don't think changing the controller.view will work as you hope, I think you may have to use:

controller.showsCameraControls = NO;
controller.cameraOverlayView = self.view;

but that's just a guess.

NWCoder
  • 5,296
  • 1
  • 26
  • 23
  • //Setting the controller OverLayView as self view imageController.cameraOverlayView = self.view; // Display imageController as a modal child. Uses a vertical sheet transition if animated. [self presentModalViewController:imageController animated:YES]; –  Apr 15 '11 at 07:39