Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing image from UIImageView

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 UIImageView appears black again?

The

UIImageView

is connected through IB.

like image 739
4thSpace Avatar asked Jan 02 '10 16:01

4thSpace


2 Answers

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?

like image 194
Tammen Bruccoleri Avatar answered Oct 09 '22 20:10

Tammen Bruccoleri


Try stating [self.imageView setNeedsDisplay]; after your image setting to nil. This will trigger a redraw of that element on the next runloop cycle I believe. Aka you are marking this view as 'dirty' and needs a redraw.

like image 34
theprojectabot Avatar answered Oct 09 '22 19:10

theprojectabot