Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialharshil bhatt
Courses Plus Student 2,722 Pointswhen i click a button in the navigation view controller , the view changes but only once the rest of the time it repeats
class ColorPagesView: UIViewController { var ColorProviderNames : Colors? var Pages : ColorPagesView?
var Number = 1
@objc func GoNextPage() {
//Pages?.PagesList[+1]
Number = Number + 1
switch Number {
case 1 : Pages = ColorPagesView(ColorsChoose: .Red)
case 2: Pages = ColorPagesView(ColorsChoose: .Blue)
case 3 : Pages = ColorPagesView(ColorsChoose: .Green)
case 4 : Pages = ColorPagesView(ColorsChoose: .Yellow)
default:
Pages = ColorPagesView(ColorsChoose: .Yellow)
}
navigationController?.pushViewController(Pages!, animated: true)
}
//Right now the Pages is Nil , when i click the button , the view changes once and then just gets repeating the same , i want in a way where every time i click the button , the view gets updated , here the var 'Number' goes to 2 then never get 3
//i Programmed it that when the number gets added by 1 the navigation view also changes