please see below code. shows animation effect image.
uiimageview *imgview = [[uiimageview alloc] initwithimage:img]; // ref count = 1 int offx = imgview.frame.size.width / 6; int offy = (imgview.frame.size.height - 44) / 6; imgview.frame = cgrectmake(offx, offy, imgview.frame.size.width - offx * 2, (imgview.frame.size.height - 44) - offy * 2); [overlayview addsubview:imgview]; // ref count = 2 [imgview release]; // ref count = 1 [uiview animatewithduration:1.0 animations:^{ [imgview setcenter:cgpointmake(trash_x, trash_y)]; [imgview settransform:cgaffinetransformmakescale(0.1, 0.1)]; [imgview setalpha:0.5]; } completion:^(bool finished) { [imgview removefromsuperview]; // ref count = 0? destroy imgview object? }];
from above code, if remove [imgview release] there no crash. but, above code makes crash completion routine. why? think reference count changed comment. there should no crash.
could please explain why completion routine makes crash?
ok. solved problem. in fact, problem not in code showed. there no problem in code.
the reason of crash related 'img' object used initial argument of uiimageview. actually, accidentally released 1 more time other place.
i think when uiimageview object deallocated try release it's image object. but, it's deallocate so, crash happend. looks [imgview removefromsuperview] makes crash.
sorry fuss.
Comments
Post a Comment