我尝试学习如何执行自定义塞格斯这样我就可以有一个游戏菜单,当我在网上搜索,就好像你必须做出一个自定义的SEGUE类,并覆盖-(void) perform
并在这方法,你必须指定一个组成目标vc和源vc。并建立它的位置和东西。这是我在互联网上看到的代码之一。目标vc和源vc有什么区别?
@implementation FromTopReplaceSegue
-(void)perform{
UIViewController *dst = [self destinationViewController];
UIViewController *src = [self sourceViewController];
[dst viewWillAppear:NO];
[dst viewDidAppear:NO];
[src.view addSubview:dst.view];
CGRect original = dst.view.frame;
dst.view.frame = CGRectMake(dst.view.frame.origin.x, 0-dst.view.frame.size.height, dst.view.frame.size.width, dst.view.frame.size.height);
[UIView beginAnimations:nil context:nil];
dst.view.frame = CGRectMake(original.origin.x, original.origin.y, original.size.height, original.size.width);
[UIView commitAnimations];
[self performSelector:@selector(animationDone:) withObject:dst afterDelay:0.2f];
}
- (void)animationDone:(id)vc{
UIViewController *dst = (UIViewController*)vc;
UINavigationController *nav = [[self sourceViewController] navigationController];
[nav popViewControllerAnimated:NO];
[nav pushViewController:dst animated:NO];
}
@end
我想这应该是一个从顶端出现下降或什么的segue。但我有几个问题,如什么是一个源和目标vc,并在代码所说的部分dst.view.fram=CGRectMake(dst.view.frame.origin.x, 0-dst.view.frame.size.height,
什么是在那里,0,不应该是dst.view.frame.origin.y
?
好吧,无论如何,我把它连接起来,并从一个按钮创建了一个push segue,但是当我这样做的时候,segue只是从屏幕的顶部向下约3/4,而底部1/4显示我的根视图底部。还有当我试图在程序崩溃后在我的新vc上按下按钮时。
任何信息将帮助请!
非常有帮助谢谢! – bmende 2012-08-01 23:19:51