Does anyone know how to enable the photo album button on the UIImagePickerController when its in the camera mode? Like how the camera app on on the iphone can toggle between image and video taking and also has the button to view the photo library?
expo-image-picker provides access to the system's UI for selecting images and videos from the phone's library or taking a photo with the camera.
A view controller that manages the system interfaces for taking pictures, recording movies, and choosing items from the user's media library.
This can be done via the following lines:
- (void) navigationController: (UINavigationController *) navigationController willShowViewController: (UIViewController *) viewController animated: (BOOL) animated {
if (imagePickerController.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(showCamera:)];
viewController.navigationItem.rightBarButtonItems = [NSArray arrayWithObject:button];
} else {
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithTitle:@"Library" style:UIBarButtonItemStylePlain target:self action:@selector(showLibrary:)];
viewController.navigationItem.leftBarButtonItems = [NSArray arrayWithObject:button];
viewController.navigationItem.title = @"Take Photo";
viewController.navigationController.navigationBarHidden = NO; // important
}
}
- (void) showCamera: (id) sender {
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
}
- (void) showLibrary: (id) sender {
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With