我发现这段代码用于良好的转换:
http://srooltheknife.blogspot.co.uk/2012/03/custom-transition-animation-for-modal.html
问题是它使用'modal'而我的程序使用ARC,因此在iOS 6.0中不推荐使用modal。
只有两行使用模态,所以我从 -
更改了它们TransitionController.m:
[self dismissModalViewControllerAnimated:NO];
to:
[self dismissViewControllerAnimated:NO completion:Nil];
和
[self presentModalViewController:modalViewController animated:NO];
to:
[self presentViewController:modalViewController animated:NO completion:nil];
我执行它:
FirstPage.m:
@implementation FirstPage
{
TransitionController *tran;
}
- (IBAction)StartGame:(id)sender
{
if (! self.mainPage)
self.mainPage = [[MainGameDisplay alloc] initWithNibName:nil bundle:nil];
[tran presentModalViewController:self.mainPage withPushDirection:kCATransitionFromBottom];
}
StartGame是一个按钮。该程序运行完美,没有错误,但是当我点击按钮时没有任何反应。
更新:
FirstPage.h:
#import <UIKit/UIKit.h>
#import "MainGameDisplay.h"
#import <QuartzCore/QuartzCore.h>
#import "TransitionController.h"
@interface ViewController : Engine
{ }
- (IBAction)StartGame:(id)sender; //Action connection ID.
@property(nonatomic, readwrite) MainGameDisplay *mainPage;
FirstPage.m:
@implementation ViewController
{
TransitionController *tran;
}
- (IBAction)StartGame:(id)sender {
if (! self.mainPage)
self.mainPage = [[MainGameDisplay alloc] initWithNibName:nil bundle:nil];
tran = [[TransitionController alloc] initWithNibName:Nil bundle:Nil];
[tran presentModalViewController: self.mainPage withPushDirection:kCATransitionFromBottom];
}