2

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

2 に答える 2

7

自分自身をプッシュする代わりに、同じクラスの新しいインスタンスをインスタンス化し、の代わりにそれをプッシュする必要がありますself。次に、関連するデータを取得して、-viewDidLoadメソッドのインターフェースに解析できます。

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];
于 2012-05-25T23:51:37.073 に答える
0

のドキュメントからpushViewController:animated:

ビューコントローラー

スタックにプッシュされるビュー コントローラー。このオブジェクトは、タブ バー コントローラーのインスタンスにすることはできません。また、ナビゲーション スタック上にまだ存在していてはなりません。

selfナビゲーション スタックをプッシュし続けます。既にスタック上にあるため、ナビゲーション コントローラーはプッシュを無視している可能性が高く、ビュー内のラベルを変更しているため、アニメーションなしでラベルが変更されているように見えます。(まさにそれが起こっているからです。)

于 2012-05-25T23:48:51.940 に答える