Old uiimage object sticks around in new uiimageview


#1

So i am using the Navigation controller to handle two view controllers. One being ItemsViewController that is the root view controller of the NavController.

The second controller named DetailViewController is pushed on top of ItemsViewController. This way i’ve made a drill-down UI using these 2 controllers. Now inside DetailViewController i’ve added a couple of subviews like buttons, textfields, labels and an imageView.

The imageView pointer that is declared inside of DetailViewController is of type ‘weak’, so whenever the view controller’s main view is cleared off, the old imageView object doesn’t hang around.

When i go back from DetailViewController’s view to ItemsViewController’s table view, the former is loaded off the parent-child controller stack (rightfully so) so that when i re-enter the DetailViewController’s view (same one as before),it is reloaded and thus recreating a UIView all over again.

Thus the new UIView has got all the new subview objects created. But (and this is the problem), the old image object in the new imageView object is still there. Why should the old image object (which is also added as a hash table member) be appearing after the DetailViewController’ view is reloaded and hence all the all subviews (like imageView object) are reloaded too?

Conceptually,
[currentImageView image]!= nil (it holds the current image object)
after reloading––
[newImageView image] == nil (newImageView should be having no image object unless explicitly set)

This is confusing me. Could someone clear this up?