2012-08-06 163 views
5

如何從一個模態賽格瑞顯示這樣的模式時刪除過渡效果:模態Segue公司沒有過渡

[self performSegueWithIdentifier:@"SomeIdentifier" sender:self]; 

我知道我可以去到故事板和4個不同的動畫之間進行切換,但我不知道想要任何!我如何刪除它們?

我知道我可以說presentModalViewController animated: NO但我沒有也不能用這種方式調用它。我需要使用performSegueWithIdentifier方法。

回答

9

如果你需要一個segue但不想動畫,你需要製作一個自定義的segue(沒有動畫)。

你應該看看蘋果"creating custom segues" example在視圖控制器編程指南,他們沒有動畫(就像你想要的)做一個自定義模態segue。

+0

優秀muchos gracias。 – MobileMon 2012-08-07 11:12:56

11

這裏是一個沒有動畫SEGUE的全部源:

BVNoAnimationSegue.h

#import <UIKit/UIKit.h> 
@interface BVNoAnimationSegue : UIStoryboardSegue 
@end 

BVNoAnimationSegue.m

#import "BVNoAnimationSegue.h" 

@implementation BVNoAnimationSegue 

- (void)perform 
{ 
    [[self sourceViewController] presentModalViewController:[self destinationViewController] animated:NO]; 
} 

@end 

要利用這一點,添加文件到您的項目(例如BVNoAnimationSegue.m/.h),然後在故事板中選擇「Custom」作爲您的Segue類型和類型BVNoAnimationSegue在Segue類框中。完成這個之後,Xcode似乎足夠聰明,可以在將來在UIViewControllers之間進行CTRL拖動時添加「no animation segue」作爲選項。

15

在故事板中,您可以選擇您的segue,並在屬性檢查器中取消選中「動畫」。這應該做到這一點。

+1

最佳答案!這應該是官方的答案! – 2013-11-29 20:39:11

+5

這隻適用於Modal風格,沒有「Animates」選項可供推送 – 2014-01-17 04:54:55

-1

另一種方式,我們可以

YourViewController *aYourViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"aYourViewControllerIdentifier"]; 
[self.navigationController pushViewController:aYourViewController animated:NO]; 

,並添加@"aYourViewControllerIdentifier"在你的故事板,查看控制器。