Okay let me give you an overview of what happens so far. I have three questions in an array. Every time the 'Next' button is pressed, it will slide to the next question in the array. What I would like to happen, is when the next question in the array is pressed, it moves the progress bar along. I don't need to do anything with the value of the progress bar, it's just really there for design.
Currently, I have the code all set, so that when you press the Next button for the first time, it moves the progress bar to the value 0.333, but when you press it again, it doesn't move again, it just stays where it is.
Can someone please help, as I've been trying to figure this out for a while and just have no luck. My code showing what I have to make it initially move is below:
@IBOutlet var progressStatus: UIProgressView!
@IBAction func nextButton(sender: AnyObject) {
// Displays the questions in array and displays the placeholder text in the textfield
if currentQuestionIndex <= questions.count && currentPlaceholderIndex <= placeholder.count {
currentQuestionIndex++
currentPlaceholderIndex++
progressStatus.setProgress(0.333, animated: true)
buttonLabel.setTitle("Next", forState: UIControlState.Normal)
}
Thanks in advance!
CODE TO ANSWER MY ISSUE:
if currentQuestionIndex == 0 {
progressStatus.setProgress(0.333, animated: true)
} else if currentQuestionIndex == 1 {
progressStatus.setProgress(0.666, animated: true)
} else {
progressStatus.setProgress(1, animated: true)
}
I'm not sure what the fix would be at this time, since I'm still learning swift at the moment, so just give you an idea. But I think it is something with the value you set, the 0.333. With the code you have right now, you are setting it to the value 0.333, not increase it by 0.333. Maybe you can use a if loop through the questions. Something like, if question == 1, setProgress(0.333), if question == 2, setProgress(0.666)