作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我在设备(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
[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/
我在设备上运行我的应用时遇到以下错误(我没有在模拟器中运行它): CGImageCreateWithImageProvider`:无效的图片尺寸:180 x 180。 - (IBAction)choo
当我在设备(8.0.2)(而不是模拟器)上运行我的应用程序时,同时存在两个错误。 一个是 : CGImageCreateWithImageProvider: invalid image size: 1
我在 NSImage 扩展中有一个方法 cgImageSlice,它应该返回包含每个图像切片的 [CGImage]。运行代码时,在第 18 行的第一个循环后,我收到错误 CGImageCreateWi
我是一名优秀的程序员,十分优秀!