mardi 23 décembre 2014

Comparing contents within UIImage to user input

How can I go about comparing the contents of a UIImage to the users input from a UITextField? Please assume the UIImageView is already assigned an image.


Also, are there any suggestions to the below code?



@IBOutlet var CelebrityPic: UIImageView!
@IBOutlet var YouIsRight: UIImageView!
@IBOutlet var TotalPoints: UILabel!
@IBOutlet var nextBTNOUT: UIButton!



@IBAction func responseAction(EnterHere: UITextField) { //If image is equal to user input
if (CelebrityPic == "\(EnterHere.text)"){
YouIsRight.image = UIImage(named: "Correct")
YouIsRight.hidden = false
counterNumber += 100
TotalPoints.text = "Total points: \(counterNumber)"
nextBTNOUT.hidden = false
}
if (CelebrityPic != "\(EnterHere.text)"){ //If image is not equal to user input
YouIsRight.image = UIImage(named: "Incorrect")
YouIsRight.hidden = false
counterNumber -= 100
TotalPoints.text = "Total points: \(counterNumber)"
nextBTNOUT.hidden = false

}
}

Aucun commentaire:

Enregistrer un commentaire