不使用动画 segue 应用程序崩溃



我正在使用UIStoryboardSegue子类来抑制推送动画segue。

#import "NoAnimationSegue.h"
@implementation NoAnimationSegue
- (void)perform
{
    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;
    NSLog(@"src %@", src);
    [src.navigationController pushViewController:dst animated:NO];
}
@end

在某些情况下,使用此 segue 会使我的应用程序崩溃。当我禁用此代码并改用推送 segue 时,它工作正常。

有什么想法吗?

上面的代码对我来说工作正常。你如何在这个子类化 segue 中调用"执行"方法?我用以下示例检查了您的子类,它工作正常,您能否编写用于调用"执行"方法的代码?

SecondViewController *second = [[SecondViewController alloc] init];
NoAnimationSegue *animate = [[NoAnimationSegue alloc] initWithIdentifier:@"1" source:self destination:second];
[animate perform];
出现

此问题是因为我在故事板中添加了一个手势识别器到我的destinationViewController

当我删除手势识别器或通过代码添加识别器时......它工作正常。

最新更新