-
-
Save bsdshell/31d56609ead81258c985 to your computer and use it in GitHub Desktop.
UIImagePickerController simple example, Override camera button, OverlayView example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>{ | |
NSMutableArray* _capturedImages; | |
} | |
@property(nonatomic, retain)NSMutableArray* capturedImages; | |
@end | |
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init]; | |
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext; | |
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; | |
if (imagePickerController.sourceType == UIImagePickerControllerSourceTypeCamera){ | |
imagePickerController.showsCameraControls = NO; | |
imagePickerController.cameraOverlayView = self.overlayView; | |
imagePickerController.delegate = self; | |
self.overlayView = nil; | |
} | |
self.imagePickerController = imagePickerController; | |
// The method have to pass (id)sender as parameter in order to work:) | |
- (void)takePicture:(id)sender | |
{ | |
NSLog(@"takePicture()"); | |
[self.imagePickerController takePicture]; | |
} | |
#pragma mark - UIImagePickerControllerDelegate | |
// This method is called when an image has been chosen from the library or taken from the camera. | |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info | |
{ | |
UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage]; | |
[self.capturedImages addObject:image]; | |
} | |
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker | |
{ | |
[self dismissViewControllerAnimated:YES completion:NULL]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Two Lines are important
imagePickerController.showsCameraControls = NO;
UIView* overlayView = [UIView alloc]init];
imagePickerController.cameraOverlayView = self.overlayView;