views:

821

answers:

1

I load a UIImageView with an image depending on user interaction. When the parent view is initially displayed, no image has been selected and the imageview is black. If the user leaves that view and comes back, the image is still there. I've tried

myImageView.image = nil;

upon leaving the view but the image remains. How can I remove the image so the imageview appears black again?

The UIImageView is connected through IB.

+3  A: 

Setting the UIImageView as:

myImageView.image = nil 

is the correct way to clear an UIImageView. Are you loading the image when your calling function returns? Is your UIImageView being declared, and/or used elsewhere in your main function?

Tammen Bruccoleri
For some reason, it is working now. I don't know that I did anything different. Thanks.
4thSpace
Agreed; this is how you clear the image. The most likely cause is that the nil assignment is not actually being called.
Rob Napier