【问题标题】:Modal segue no transition模态转场无过渡
【发布时间】:2012-08-06 19:39:07
【问题描述】:
当像这样显示模态时如何从模态转场中移除过渡效果:
[self performSegueWithIdentifier:@"SomeIdentifier" sender:self];
我知道我可以进入情节提要并在 4 个不同的动画之间切换,但我不想要任何一个!如何删除它们?
我知道我可以说presentModalViewController animated: NO,但我不会也不能这样称呼它。我需要使用performSegueWithIdentifier 方法。
【问题讨论】:
标签:
objective-c
ios
storyboard
modalviewcontroller
【解决方案1】:
在情节提要中,您可以选择转场并在属性检查器中取消选中“动画”。应该这样做。
【解决方案2】:
这是无动画转场的完整来源:
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),然后在情节提要中,选择“自定义”作为您的 Segue 类型并在 Segue Class 框中键入 BVNoAnimationSegue .完成此操作后,Xcode 似乎足够聪明,可以在将来在 UIViewController 之间按住 CTRL 拖动时添加“无动画转场”作为选项。
【解决方案4】:
另一种方法
YourViewController *aYourViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"aYourViewControllerIdentifier"];
[self.navigationController pushViewController:aYourViewController animated:NO];
并将@"aYourViewControllerIdentifier" 添加到情节提要中的视图控制器。