ios - CFRelease causing crash in iPad application -
i trying merge 4 images make 1 uiimage. when going cfrelease, crashing. if don't this, giving memory leak , crashing. how resolved?
see below code.
referenceview.frame = cgrectmake(0, 0, 1024, 768); referenceview.hidden = no; [self.view insertsubview:referenceview belowsubview:selfview]; imgview1.image = delegate.imagecroped; imgview2.image = [uiimage imagenamed:@"videobg.png"]; imgview3.image = [uiimage imagenamed:@"videochar.png"];; imgview4.image = smileview.image; imgview1.frame = cgrectmake(456, 311, delegate.imagecroped.size.width-30.8, delegate.imagecroped.size.height-40); imgview2.frame = cgrectmake(0, 0, 1024, 768); imgview3.frame = cgrectmake(392, 187, imgview3.image.size.width, imgview3.image.size.height); imgview4.frame = cgrectmake((smileview.frame.origin.x-((smileview.frame.origin.x > 530) ? 30 : 15)), (smileview.frame.origin.y+((smileview.frame.origin.y <= 307) ? 95 : 50)), smileview.frame.size.width, smileview.frame.size.height); [referenceview addsubview:imgview1]; [referenceview addsubview:imgview2]; [referenceview addsubview:imgview3]; [referenceview addsubview:imgview4]; uigraphicsbeginimagecontext(referenceview.bounds.size); [referenceview.layer renderincontext:uigraphicsgetcurrentcontext()]; cgimageref finalimage = ( cgimageref)(uigraphicsgetimagefromcurrentimagecontext()); uigraphicsendimagecontext(); [referenceview removefromsuperview]; [imgview1 removefromsuperview]; [imgview2 removefromsuperview]; [imgview3 removefromsuperview]; [imgview4 removefromsuperview]; uiimage *resizedimage = [uiimage imagewithcgimage:finalimage]; cfrelease(finalimage); return resizedimage; } @catch (nsexception *exception) { }
and getting below error. how can fix problem? project in arc.
* -[uiimage _cftypeid]: message sent deallocated instance 0x1e88dce0
uigraphicsgetimagefromcurrentimagecontext()
returns uiimage *, not cgimageref. , don't own resulting uiimage, don't want release (or cfrelease() it).
try:
uiimage *finalimage = uigraphicsgetimagefromcurrentimagecontext();
instead.
Comments
Post a Comment