iOS:推送相同的视图控制器 [英] iOS: Push same view controller
本文介绍了iOS:推送相同的视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个按钮,并且希望使用同一控制器为默认的"UI页面幻灯片"设置动画,那么当单击下一个按钮"时如何实现?我以为这样可以用,但是不可以.
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];
}
推荐答案
您无需实例化self,而是需要实例化同一类的新实例,并将其实例化为 self
的替代品.然后,您可以在 -viewDidLoad
方法中获取相关数据并将其解析到接口中.
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];
这篇关于iOS:推送相同的视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文