打开系统默认相册功能


UIImagePickerControllerDelegate

#pragma mark - 相册
- (void)openPhotoVC{

    //判断是否有相机权限
    PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
    if (status == PHAuthorizationStatusRestricted || status == PHAuthorizationStatusDenied) {
        //无权限
        [ccs showNotice:@"无相册访问权限"];
        return;
    }
    UIImagePickerController *pickerC = [[UIImagePickerController alloc]init];
    pickerC.delegate = self ;
    pickerC.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    pickerC.modalPresentationStyle = UIModalPresentationFullScreen;
    [self.viewController presentViewController:pickerC animated:YES completion:nil];
}
  • delegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//    获取图片
    UIImage *image = info[UIImagePickerControllerOriginalImage];

}

你可能感兴趣的:(打开系统默认相册功能)