相机或者相册选照片

 UIAlertController * alter = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];     UIImagePickerController * pickImage = [[UIImagePickerController alloc]init];     pickImage.allowsEditing = YES;     pickImage.delegate = self;     __weak typeof(self)weakSelf = self;     UIAlertAction * actionXiangCe = [UIAlertAction actionWithTitle:@"从相册选择" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {         pickImage.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;         [weakSelf presentViewController:pickImage animated:YES completion:nil];     }];          UIAlertAction * actionXiangJi = [UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {         if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {             pickImage.sourceType = UIImagePickerControllerSourceTypeCamera;             [weakSelf presentViewController:pickImage animated:YES completion:nil];         }else{                      }     }];          UIAlertAction * actionCancle = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {         [weakSelf dismissViewControllerAnimated:YES completion:nil];     }];     [alter addAction:actionXiangJi];     [alter addAction:actionXiangCe];     [alter addAction:actionCancle];     [self presentViewController:alter animated:YES completion:nil];
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<UIImagePickerControllerInfoKey,id> *)info{     UIImage * newphoto = [info objectForKey:@"UIImagePickerControllerEditedImage"];
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容