Learn Courses My Dashboard

Hiding the upload button when imageView has no image

Hello @Chris_Parker,

In my storyboard scene I have an Image View and image picker button and an upload button:

I would like to keep the upload button hidden until an edited image shows up in the imageView. How would I do that? The current code isn’t detecting if there is an image in the imageView.

@IBOutlet var imageView: UIImageView!
    
    @IBOutlet var uploadBtn: UIButton!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        uploadBtn.isHidden = true
        
        if imageView.image != nil {
            
            uploadBtn.isHidden = false
        }
        

@coder3000

As far as I can tell it should work. Have you got the IBOutlets connected correctly to the buttons? What I mean is have you accidentally got them mixed up?