IOS calls the System camera and album, and ios calls the camera

Source: Internet
Author: User

IOS calls the System camera and album, and ios calls the camera
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 *) EditingInfo NS_DEPRECATED_IOS (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];

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.