gpt4 book ai didi

ios - <错误>:CGImageCreateWithImageProvider:无效的图像大小:150 x150。__connection_block_invoke_2中的错误:连接中断

转载 作者:行者123 更新时间:2023-12-01 16:29:03 25 4
gpt4 key购买 nike

当我在设备(8.0.2)(而不是模拟器)上运行我的应用程序时,同时存在两个错误。

一个是

<Error>: CGImageCreateWithImageProvider: invalid image size: 150 x 150.

另一个是
error in __connection_block_invoke_2: Connection interrupted

这是代码:
- (IBAction)chooseImage:(id)sender {

if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"choose picture"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"take photos", @"from photo album", nil];
}
else
{
self.actionSheet = [[UIActionSheet alloc] initWithTitle:@"choose picture"
delegate:self
cancelButtonTitle:@"cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"from photo album", nil];
}

self.actionSheet.tag = 1000;
[self.actionSheet showInView:self.view];
}


-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (actionSheet.tag == 1000)
{
NSUInteger sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
switch (buttonIndex)
{
case 0:
sourceType = UIImagePickerControllerSourceTypeCamera;
break;
case 1:
sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
break;
case 2:
return;
}
}
else
{
if (buttonIndex == 2)
{
return;
}
else
{
sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
}


UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.delegate = self;
imagePickerController.allowsEditing = YES;
imagePickerController.sourceType = sourceType;

[self presentViewController:imagePickerController animated:YES completion:^{

}];
}}

#pragma mark - image picker delegte

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[picker dismissViewControllerAnimated:YES completion:^{}];

UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
[self.chooseImage setImage:image forState:UIControlStateNormal];
//self.productImage.image = image;
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissViewControllerAnimated:YES completion:^{}];
}

最佳答案

这是iOS 10中的错误。

  • 方法- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info更改为- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info
  • 通过以下方式添加GCD:
     [picker dismissViewControllerAnimated:YES completion:^{}];
    dispatch_async(dispatch_get_main_queue(), ^{
    UIImage *image = [info objectForKey:UIImagePickerControllerEditedImage];
    [self.chooseImage setImage:image forState:UIControlStateNormal];
    //self.productImage.image = image;
    });
    }
  • 关于ios - <错误>:CGImageCreateWithImageProvider:无效的图像大小:150 x150。__connection_block_invoke_2中的错误:连接中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33182325/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com