iOS: Push same view controller
ios, iphone, uiview, xcode
Solution
Instead of pushing self, you need to instantiate a new instance of the same class, and push that in replace of `self`. You can then get the relevant data and parse it into the interface in your `-viewDidLoad` method.
SameClassAsSelf *new_self = [[SameClassAsSelf alloc] init...];
new_self.questionNumber = QuestionNumber;
new_self.questionsList = QuestionsList; //if needed
[self pushViewController:new_self animated:YES];
[new_self release];
Problem
If I have a button and I want to animate the default "UI Page Slide" with the same controller, how would I make that happen when the "nextbutton" is clicked? I thought this would work, but it doesn't. ``` - (IBAction)NextButton:(id)sender { [self.navigationController pushViewController:self animated:YES]; NSInteger CurrentQuestionNumber = [QuestionNumber intValue]; NSInteger NewQuestionNumber = CurrentQuestionNumber + 1; QuestionNumber = [NSString stringWithFormat:@"%d", NewQuestionNumber]; QuestionNumberLabel.text = QuestionNumber; QuestionLabel.text = [QuestionsList objectForKey:QuestionNumber]; } ```