Created
July 27, 2016 14:52
-
-
Save 000Dmyers000/646d2b972ae05ec59ceead13d8e95272 to your computer and use it in GitHub Desktop.
I would like to control an array in sequence for back and next buttons, right now it selects the items randomly "Int(arc4random_uniform)" how can I change this? (I have not added the else/if functions yet)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var slide: UIImageView! | |
@IBOutlet weak var playNextButton: UIButton! | |
var slideArray:[String] = ["slide1", "slide2", "slide3", "slide4"] | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
} | |
override func didReceiveMemoryWarning() { | |
super.didReceiveMemoryWarning() | |
// Dispose of any resources that can be recreated. | |
} | |
@IBAction func nextButton(sender: UIButton) { | |
let slide = Int(arc4random_uniform(4)) | |
let slideString:String = self.slideArray [slide] | |
self.slide.image = UIImage(named: slideString) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment