0

ボタンをクリックするとボタンがオンpage 1になり、アニメーションと新しいページへのナビゲーションが実行されますPage 2

クリックpage 2するとキャンセル ボタンが表示され、前のページに戻りたいのですPage 1が、キャンセル ボタンをクリックするとアプリがクラッシュします。

これがページCRViewControllerの名前のサンプルコードですPage 1:

- (IBAction)ClickMe:(id)sender {
    RegistraionViewController *secondController = [[RegistraionViewController alloc] init];

    CATransition *transitionAnimation = [CATransition animation];
    [transitionAnimation setDuration:1];
    [transitionAnimation setType:@"push"];
    [transitionAnimation setSubtype:kCATransitionFromBottom];
    [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

    [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFromBottom];
    [self.view addSubview:secondController.view];
}

Page 2: ページの名前にあるコードRegistraionViewController (クリックするとクラッシュします。)

- (IBAction)Click:(id)sender {
    CRViewController *secondController = [[CRViewController alloc] init];

    CATransition *transitionAnimation = [CATransition animation];
    [transitionAnimation setDuration:1];
    [transitionAnimation setType:@"push"];
    [transitionAnimation setSubtype:kCATransitionFromTop];
    [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

    [self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFromBottom];
    [self.view addSubview:secondController.view];
}
4

3 に答える 3

1

これを試して:

- (IBAction)ClickMe:(id)sender {   
    RegistraionViewController *secondController = [[RegistraionViewController alloc] init];   
    [self.navigationController pushViewController:secondController animated:YES];   
}


- (IBAction) Click:(id)sender {    
   [self.navigationController popViewControllerAnimated:YES];    
}

編集:
申し訳ありません。カスタムの UIViewController トランジション アニメーションが必要な場合は、以下を参照し

ください

- (IBAction)ClickMe:(id)sender {
    RegistraionViewController *secondController = [[RegistraionViewController alloc] init];

    CATransition *transitionAnimation = [CATransition animation];
    [transitionAnimation setDuration:1];
    [transitionAnimation setType:@"push"];
    [transitionAnimation setSubtype:kCATransitionFromBottom];
    [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

    [self.navigationController.view.layer addAnimation:transitionAnimation forKey:nil];
    [self.navigationController pushViewController:secondController animated:NO]; 
}

- (IBAction)Click:(id)sender {
    CRViewController *secondController = [[CRViewController alloc] init];

    CATransition *transitionAnimation = [CATransition animation];
    [transitionAnimation setDuration:1];
    [transitionAnimation setType:@"push"];
    [transitionAnimation setSubtype:kCATransitionFromTop];
    [transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];

    [self.navigationController.view.layer addAnimation:transitionAnimation forKey:nil];
    [self.navigationController popToViewController:secondController animated:NO];
}
于 2013-10-30T09:55:10.113 に答える