Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show camera shutter programmatically?

In order to make my custom UIImagePickerSourceTypeCamera, I had to do this:

pickerOne = [[UIImagePickerController alloc] init];
pickerOne.delegate = self;
pickerOne.sourceType = UIImagePickerControllerSourceTypeCamera;
pickerOne.showsCameraControls = NO;
pickerOne.navigationBarHidden = YES;
pickerOne.toolbarHidden = YES;
pickerOne.wantsFullScreenLayout = YES;

But now, when I take a picture like this:

[cameraButton addTarget:pickerOne 
                 action:@selector(takePicture)
       forControlEvents:UIControlEventTouchUpInside];

it doesn't show the shutter when you take the picture. Is there a way to show it programmatically?

like image 447
iosfreak Avatar asked Jan 28 '26 22:01

iosfreak


2 Answers

It is possible. The trick is to do the following:

Enable the camera controls on initializing the picker (this will enable the shutter view).

pickerOne.showsCameraControls = YES;

Overlay the camera controls with your own view which has the cameraButton

In your takePicture: method do the following:

pickerOne.showsCameraControls = NO;
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]];
[pickerOne takePicture];

In the imagePickerController:didFinishPickingMediaWithInfo: method do the following:

pickerOne.showsCameraControls = YES;  // perform on main thread
like image 74
diederikh Avatar answered Jan 30 '26 16:01

diederikh


There is no way to control the "shutter" affect. You can however create your own image and add the affect in there.

like image 33
WrightsCS Avatar answered Jan 30 '26 17:01

WrightsCS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!