Hello,
Attempting to take a screenshot when the user is in Camera mode and user hits take picture. I have an application with several tabs. In one of them the user launches the Camera. I use CameraOverViewController to make a custom button to take a picture [picker takePicture]. When this picture is taken I also a screen shot of the picture using standard methods. This all works fine in a test app with no tabs, as soon as I introduce tabs it just returns a black square. I realize its likely to do with getting the right VIEW, I can't figure out which view to get.
// the view loaded in the tab view
@interface CameraTestViewController : UIViewController |UIImagePickerControllerDelegate, UINavigationControllerDelegate|
UIImagePickerController *picker
.m
- (void) setUpCamera : (id) sender {
picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = NO;
picker.showsCameraControls = NO;
picker.wantsFullScreenLayout = YES;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_SCALAR, CAMERA_SCALAR);
CameraOverViewController *createOverlay = [[CameraOverViewController alloc] initWithNibName:@"CameraOverViewController" bundle:nil];
[createOverlay mainView:self];
[picker setCameraOverlayView:createOverlay.view];
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void) snapThePicture {
[picker takePicture];
}
// TAKE SCREEN SHOT AS WELL. WORKS WITH NO TABS
- (void)imagePickerController:(UIImagePickerController *)pickerHere didFinishPickingMediaWithInfo:(NSDictionary *)info {
// tried many, many things. self.view.layer, etc
CGRect screenRect = CGRectMake(0, 0, 320, 480);
UIGraphicsBeginImageContext(screenRect.size);
[self.picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
// UIIMAGE ALWAYS A BLACK RECTANGLE OF RIGHT SIZE. WOULD WORK IF NOT IN TAB VIEW
UIImage *screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
Any help is appreciated.
thanks.