美文网首页
相机或者相册选照片

相机或者相册选照片

作者: 恩哼恩哼蹦擦擦GH | 来源:发表于2019-04-19 14:53 被阅读0次
 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"];

相关文章

网友评论

      本文标题:相机或者相册选照片

      本文链接:https://www.haomeiwen.com/subject/cxgqgqtx.html