0

This is what i have so far. What I am trying to do is make the starting view (startUpView) to switch to the other view (creatNewGameViewController) by sliding down the screen with the new view. All it does now is switch views normally, but i really want that sliding effect. If anyone can spot the error in my code it would be much appreciated. Thanks

#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 有一个类方法,称为从视图到动画视图的转换,检查是否有帮助并告诉我它是怎么回事:)

界面视图

一条建议,你真的应该使用导航控制器、故事板或类似的东西来做那种视图转换,因为这是正确的做法。

于 2012-04-26T03:55:08.080 回答