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.showsCamera开发者_JAVA技巧Controls = 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?
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
There is no way to control the "shutter" affect. You can however create your own image and add the affect in there.
精彩评论