iphone - iOS:推送相同的 View Controller

标签 iphone ios xcode uiview

如果我有一个按钮,并且我想使用相同的 Controller 为默认的“UI Page Slide”设置动画,我该如何在单击“nextbutton”时实现这一点?我认为这行得通,但行不通。

- (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方法中将其解析到接口(interface)中。

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];

关于iphone - iOS:推送相同的 View Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10762445/

相关文章:

ios - UDP 套接字不适用于 iOS 中的 3G 网络?

ios - 在 iOS 7 上选择后 UITableViewCell 不更新

ios - 无法在 swift spritekit 中为 LaunchScreen 设置大图像

iphone - 如何从 iPhone 中的 NSString 中删除空格

ios - 错误 ITMS-9000 无效架构 x86_64、i386

swift - 在第二个 View 上显示标签值 - Swift

iphone - 图像创建函数中的内存泄漏

ios - 如何在固定位置(无滚动)的 UITableView 后面插入 imageView?

ios - 我无法将我的应用程序提交到 appStore(错误 ERROR ITMS-90685、ERROR ITMS-90347)

ios - UITabBar - 更新 alpha 值并渲染它? ( swift )