【问题标题】:Getting an error [UIImage mutableCopyWithZone:]: unrecognized selector sent to instance收到错误 [UIImage mutableCopyWithZone:]: unrecognized selector sent to instance
【发布时间】:2013-12-19 12:26:51
【问题描述】:

处理 JSON 数据并从字典中提取图像并将图像添加到数组中

  NSURL *imageurl=[NSURL URLWithString:(NSString *) Dictionry[@"product"][@"image_medium_url"]];
    NSData *data = [NSData dataWithContentsOfURL:imageurl];
    UIImage *image = [UIImage imageWithData:data];
    [self.productImageArray addObject:image];

并将这个数组复制到另一个数组

for(int i=0;i<prodReq.productNameArray.count;i++)
{

    [productimageA addObject:[[prodReq.productImageArray objectAtIndex:i] mutableCopy]];
}

并将图像设置为图像视图

UIImageView *productimage=[[UIImageView alloc]initWithFrame:CGRectMake(15, prodimgY, 60, 75 )];
    productimage.image=[productimageA objectAtIndex:indexPath.row];

当我运行项目时出现此错误

 -[UIImage mutableCopyWithZone:]: unrecognized selector sent to instance 0x14581240

可能出了什么问题?

【问题讨论】:

    标签: ios objective-c uiimage


    【解决方案1】:

    您正在将 UIImage 添加到 productImageArray。您不需要为 UIImage 对象添加 mutableCopy。所以只需使用

    [productimageA addObject:[prodReq.productImageArray objectAtIndex:i] ];
    

    【讨论】:

      【解决方案2】:

      UIImage 对象是不可变的,因此您不能对它们调用 mutableCopy

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-05-22
        • 1970-01-01
        相关资源
        最近更新 更多