I’m developing a iOs app for iPad. I would like to delete two objects (UIImage and UIImageView) that are created by code.
UIImage *imatgetemporal = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[popover dismissPopoverAnimated:YES];
UIImageView *img = [[UIImageView alloc] initWithImage:imatgetemporal];
How can I do it?
Thanks!
An easy way to delete things is to set them to
nil. So you might haveYou could keep the UIImageView alive but simply change out the image it displays by updating the
imageproperty of the UIImageView with a new image.When you remove an item from the superview you are simply taking it off of the screen. It is still in memory.
Something that is unclear to me from your code is how you are persisting the objects. I assume that you are setting the
UIImageViewto a property somewhere. if that’s the case, I would expect that your code above looks like (I am using a property called mainImageView for an example)or you could even reuse the
UIImageViewproperty you have each time (this assumes you only want to display one image at a time) and just replace the image with a new one.