0
Fala galera...
I am developing an app, but it is with an optional error (I believe that is the error), I have the following scenario: A button "A" and a "B" in a main Viewcontroller(1) when clicking the button "A" would have to open a second Viewcontroller(2) with the image "X" and when clicking the button "B" open the same Viewcontroller(2) but loading the "Y" image. If no image, Viewcontroller(2) normally opens.
Syntax to load the image I believe to be correct:
@IBOutlet weak var fundo: UIImageView!
@IBAction func botaAcao(_ sender: Any) {
let imagem = UIImage(named: "imagem1.jpg")!
fundo.image = imagem
}
because when placing an Imageview in the main Viewcontroller(1) the image loads normally, but when trying to open in the second Viewcontroller(2).
From the following error:
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
Blz Alberto. Thanks for the comment, I already managed to resolve. Actually it was linked straight. I decided using follows, as I had several buttons and for each button a different background would open, the best was to use this way... if follows.Identifier == "boot 1"{ Let vcDestination = follows.Destination as! Newviewcontroller vcDestination.imgBotao = 1 But thank you...
– Rodrigo Viana