【问题标题】:Error in getting CGImage from UIImage从 UIImage 获取 CGImage 时出错
【发布时间】:2014-05-09 08:21:04
【问题描述】:

当我们编写时它工作正常: UIImage *img=[UIImage imageNamed:@"ImageName"];

但是当尝试从 nsdata 制作 uiimage 时,例如:UIImage *img = [UIImage imageWithData:imageData]; 现在,当我们尝试在 draw rect 中从 img 获取 cgimage 时,它​​会给出 badAccess。 如果有人知道确切的写作方式,请给我解决方案。 我使用 CGImageRef sourceImageRef = [img CGImage];在 UIView 的 Draw Rect 方法中。

【问题讨论】:

标签: ios


【解决方案1】:

尝试将UIImage 转换为CGImage -

CGImage imageRef = imageObject.CGImage

【讨论】:

    【解决方案2】:

    你应该像这样使用alloc init:

    UIImage* myImage = [[UIImage alloc] initWithCGImage:myCGImage];
    

    【讨论】:

      猜你喜欢
      • 2011-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-01
      • 1970-01-01
      相关资源
      最近更新 更多