I have an imageView with an outlet called humanEyesUIIV and now simply want to add an image programmatically. I use the following code:
humanEyesArray = [
UIImage(named: "humanEyes0")!
]
humanEyesUIIV.image? = humanEyesArray[0]
No error shows and the simulator runs fine, but the picture doesn't show up for some reason. I have looked at this thread and the code there works fine:
How do you create a UIImage View Programmatically - Swift
let imageName = "yourImage.png"
let image = UIImage(named: imageName)
let imageView = UIImageView(image: image!)
imageView.frame = CGRect(x: 0, y: 0, width: 100, height: 200)
view.addSubview(imageView)
The problem is just that I want to insert the imageView in the UI and handle its constraints and so on there, then simple add the image programatically. Any ideas what's wrong with my code?