I want to change the image depending on the variable, I'm not sure how I can do that.
I think the code I have is right, however in the iOS simulator the image just comes up as blank. I wonder why?
Here is my code below:
import UIKit
class BuyTicketViewController: UIViewController {
@IBOutlet weak var stadiumImage: UIImageView!
@IBOutlet weak var logoImage: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
if (globalVenueSelected == "Gillingham Football Club"){
let imageGillinghmaFootballClub : UIImage = UIImage(named: "gillinghamStadium.jpg")!
let stadiumImage = (image: imageGillinghmaFootballClub)
}
if (globalVenueSelected == "Old Trafford"){
let imageOldTraffordFootballClub : UIImage = UIImage(named: "oldTraffordStadium.jpg")!
let stadiumImage = (image: imageOldTraffordFootballClub)
}
if (globalVenueSelected == "Emirates Stadium"){
let imageEmiratesFootballClub : UIImage = UIImage(named: "emiratesStadium.jpg")!
let stadiumImage = (image: imageEmiratesFootballClub)
}
if (globalVenueSelected == "Wembley"){
let imageWembley : UIImage = UIImage(named: "wemblyStadium.jpg")!
let stadiumImage = (image: imageWembley)
}
if (globalVenueSelected == "O2 Arena"){
let imageO2Arena : UIImage = UIImage(named: "o2ArenaStadium.jpg")!
let stadiumImage = (image: imageO2Arena)
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Oh, and by the way, the variable globalVenueSelected is a global variable, I don't know if that affects anything but it may change the code.
Any help is appreciated, thank you.