0

これは私がこれまでに持っているものです。私がやろうとしているのは、新しいビューで画面を下にスライドさせて、開始ビュー(startUpView)を他のビュー(creatNewGameViewController)に切り替えることです。今は普通にビューを切り替えるだけですが、私は本当にそのスライド効果が欲しいです。誰かが私のコードのエラーを見つけることができれば、それは大いにありがたいです。ありがとう

#import "CreateNewGameViewController.h"
@synthesize createNewGameViewController;
UIButton *mainCreateGame = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[mainCreateGame addTarget:self
                   action:@selector(goToCreateGameViewController)
         forControlEvents:UIControlEventTouchUpInside];
[mainScroll addSubview:mainCreateGame];
mainCreateGame.frame = CGRectMake(65, 10, 190, 60);

-(void)goToCreateGameViewController{
CreateNewGameViewController *newGame = [[CreateNewGameViewController alloc]initWithNibName:@"CreateNewGameViewController" bundle:nil];
self.createNewGameViewController = newGame;

CATransition *transition = [CATransition animation];
transition.duration = 2;
transition.timingFunction = [CAMediaTimingFunction      
                             functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type =kCATransitionMoveIn;


CATransition *transition1 = [CATransition animation];
transition1.duration = 2;
transition1.timingFunction = [CAMediaTimingFunction      
                             functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition1.type =kCATransitionMoveIn;
transition1.subtype =kCATransitionFromTop;

transition1.delegate   = self;

[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil];
transition1.subtype =kCATransitionFromTop;

transition1.delegate = self;



[self presentModalViewController:newGame animated:NO];
[self.view insertSubview:newGame.view atIndex:0];

[createNewGameViewController.view.layer addAnimation:transition1 forKey:nil]; 

[newGame release];
4

1 に答える 1

0

UIViewには、ビューからビューへのトランジションと呼ばれるクラスメソッドがあり、それが役立つかどうかを確認し、それがどうだったか教えてください:)

UiView

アドバイスの 1 つとして、ナビゲーション コントローラーやストーリーボードなどを使用して、そのようなビューの遷移を行う必要があります。これが適切な方法だからです。

于 2012-04-26T03:55:08.080 に答える