简体   繁体   中英

Error in getting CGImage from UIImage

its work fine when we write: UIImage *img=[UIImage imageNamed:@"ImageName"];

but when try to make uiimage from nsdata like:UIImage *img = [UIImage imageWithData:imageData]; now when we try to get cgimage from img in draw rect then it gives badAccess. if somebody know the exact way to write then please give me solution. i use CGImageRef sourceImageRef = [img CGImage]; in Draw Rect method of UIView.

尝试将UIImage转换为CGImage

CGImage imageRef = imageObject.CGImage

您应该像这样使用alloc init:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM