Home Random image core- Background shows up when button tapped
Reply: 0

Random image core- Background shows up when button tapped

user1074
1#
user1074 Published in July 21, 2018, 8:49 pm

I'm trying to generate random images when I tap a button, but when I tap the button, both images disappear and only the background shows up.

Here is my code:

@IBAction func PickerTapped(sender: UIButton) {

    //randomize a number for the first image

    var firstrandomNumber = arc4random_uniform(7) + 1

    //construct a string with a random number

    var firstLeftHandImageString: String = String(format: "rud%i", firstrandomNumber)

    // set the left hand image view to the asset corresponding to the randomized number

    self.LeftHandImageView.image = UIImage(named: "firstLeftHandImageString")

    //randomize a number for the second image

    var secondrandomNumber = arc4random_uniform(7) + 1

    //construct a string with a random number 

    var secondRightHandImageString: String = String(format: "rud%i", secondrandomNumber)

    //set the right hand image view to the asset corresponding to the randomized number

    self.RightHandImageView.image = UIImage(named: "secondRightHandImageString")
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32284 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO