i have built an app with a quiz section. the quiz has 4 sections after each section it unwinds to the test home screen to store the results and then segue to the next section. after the last section it returns to the test home and sends all the gathered scores from all the sections to a results screen. thats where the the problem starts the showResultsScreen segue works passing the results and displaying them but the only stay on the screen for less than a second when the test home takes over again. there no no code in the resultsScreenViewController that is calling the segue. The only thing i can think is causing it is that section4 -> quizHome is an unwindSegue and the one from quizHome -> Results is a regular show segue. do they behave differently?
section4 -> quizHome
@IBAction func finishQuizAction(sender: AnyObject) {
if(answerOne.selectedSegmentIndex == 1 ||
answerTwo.selectedSegmentIndex == 1 ||
answerThree.selectedSegmentIndex == 0){
needsTest = true
}else if(answerOne.selectedSegmentIndex == 0 ||
answerTwo.selectedSegmentIndex == 0 ||
answerThree.selectedSegmentIndex == 1){
needsTest = false
}
performSegueWithIdentifier("exitSectionFour", sender: self)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
let dest = segue.destinationViewController as! EyeTestViewController
dest.isFinished = true
dest.testNo++
}
quizhome -> Results
func displayResults(){
isFinished = true
print("this is where we should segue to results")
performSegueWithIdentifier("goToResults", sender: nil)
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if(isFinished){
print("test no. going to Results = \(testNo)------")
let resultsScreen = segue.destinationViewController as! ResultsScreenViewController
resultsScreen.secOnePartOne = "\(secOnePartOneScore) Out of 6"
resultsScreen.secOnePartTwo = "\(secOnePartTwoScore) Out of 6"
resultsScreen.secTwo = "\(secTwoScore) Out of 12"
if(secThree[0] == true){
resultsScreen.secThreeScore = "Pass"
} else if(secThreeScore[0] == false){
resultsScreen.secThreeScore = "Fail"
needsTest = true
}
if(secThree[1] == true){
resultsScreen.secThreeScore = "Pass"
} else if(secThree[1] == false){
resultsScreen.secThreeScore = "Fail"
needsTest = true
}
var leftSecFour = 0
var rightSecFour = 0
for (var x = 0; x < secFour.count; x++ ){
if(x == 0 || x == 1){
if(secFour[x] == true){
leftSecFour++
}
}else if(x == 2 || x == 3){
if(secFour[x] == true){
rightSecFour++
}
}
}
if((leftSecFour + rightSecFour) < 4){
needsTest = true
}
resultsScreen.leftSecFour = "\(leftSecFourScore) Out of 2"
resultsScreen.rightSec = "\(rightSecFourScore) Out of 2"
// recomendation
if(leftSecFourScore < 5 || rightSecFourScore < 5){
needsTest = true
}
if(needsTest){
resultsScreen.recomendationText = "Un Lucy Message"
}else{
resultsScreen.recomendationText = "Congratulations!"
}
isFinished = false
}
}// end prepareForSegue
there is only a few lines of code in resultsScreenViewcontroller to set the text labels with the scores