iOS 禁用 push segue 动画

iOS disable push segue animation

我有一个包含各种 segue 的故事板,用于在 NavigationController 中推送 ViewController。

在情节提要中我禁用了动画:

然而,推送仍在进行中。为什么?

该动画是默认行为。您需要像这样创建自定义 UIStoryBoardSegue:

PushNoAnimationSegue.h 是:

#import <UIKit/UIKit.h>

@interface PushNoAnimationSegue : UIStoryboardSegue

@end

PushNoAnimationSegue.m 是:

#import "PushNoAnimationSegue.h"

@implementation PushNoAnimationSegue

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

@end

对于每个 segue,现在将 class 更改为您刚刚创建的这个,然后在类型下拉菜单中选择 "custom"。