我嘗試學習如何執行自定義塞格斯這樣我就可以有一個遊戲菜單,當我在網上搜索,就好像你必須做出一個自定義的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