I'm creating an app that will control climate. The value changes, however, I cannot get different (Guage) images to display based on value. please help!
Here is my code
/* Fan Output Up */
@IBAction func FanOutputUpBtn(_ sender: Any) {
let name = "Fan Position\(fanCounter)"
/* Setting the name of the fan position image including the variable fanCounter */
fanPositionImage.image = UIImage(named: "fanPosition \(fanCounter)")
/* Setting the name of the fan position image including the variable fanCounter */
if fanCounter == 5 {
/* Set maximum value */
} else {
fanCounter += 1
/* Increase the fan counter position by 1 */
TestFanCounter.text = String(Int(self.fanCounter))
/* Display the counter image */
self.fanPositionImage.image = UIImage(named: name)
/* Display image for fan position based on fan counter */
}
Update
Now It's random images displaying on tap however the TestFanCounter.text = String(Int(self.fanCounter)) is displaying completly fine
/* Fan Output Up */
@IBAction func FanOutputUpBtn(_ sender: Any) {
let name = "Fan Position \(fanCounter)"
// Setting the name of the fan position image including the variable fanCounter
if fanCounter == 4 {
// Set maximum value
} else {
fanCounter += 1
// Increase the fan counter position by 1
TestFanCounter.text = String(Int(self.fanCounter))
// Display the counter image
self.fanPositionImage.image = UIImage(named: name)
/* Display image for fan position based on fan counter */
}
}