2012-08-06 107 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"在你的故事板,查看控制器。