IOS ---------- call the System camera and album,
After iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the permission to get photos and albums in plist. After iOS 10, remember to add the permission to get photos and albums in plist, after iOS 10, remember to add the photo and album permissions in plist. Limited. After iOS 10, remember to add the permission to get photos and albums in plist.
/**
* Call a camera
*/
-(Void) openCamera
{
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
Picker. delegate = self;
Picker. allowsEditing = YES; // editable
// Determine whether the camera can be opened
If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
{
// Camera
Picker. sourceType = UIImagePickerControllerSourceTypeCamera;
[Self presentViewController: picker animated: YES completion: nil];
}
Else
{
NSLog (@ "no camera ");
}
}
/**
* Open an album
*/
-(Void) openPhotoLibrary
{
// Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES
// Enter the album
If ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypePhotoLibrary])
{
UIImagePickerController * imagePicker = [[UIImagePickerController alloc] init];
ImagePicker. allowsEditing = YES;
ImagePicker. sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
ImagePicker. delegate = self;
[Self presentViewController: imagePicker animated: YES completion: ^ {
NSLog (@ "Open album ");
}];
}
Else
{
NSLog (@ "album cannot be opened ");
}
}
# Pragma mark-UIImagePickerControllerDelegate
// Callback after taking a photo
-(Void) imagePickerController :( UIImagePickerController *) picker didFinishPickingImage :( UIImage *) image editingInfo :( nullable NSDictionary <NSString *, id> *) editingInfo partition (2_0, 3_0)
{
NSLog (@ "finish ..");
If (picker. sourceType = UIImagePickerControllerSourceTypeCamera)
{
// Save the image to the album
UIImageWriteToSavedPhotosAlbum (image, nil );
}
[Self dismissViewControllerAnimated: YES completion: nil];
}
// Go to the shooting page and click the cancel button.
-(Void) imagePickerControllerDidCancel :( UIImagePickerController *) picker
{
[Self dismissViewControllerAnimated: YES completion: nil];
}