ios - 自定义 Segue 动画不工作

标签 ios animation storyboard scene

我有一个为自定义转场动画编写的自定义类。我正在尝试自定义动画点击手势。在我的 Storyboard中,我有一个导航 Controller 、主视图和另外两个 View 。我将手势连接到另一个 View ,并定义了要使用的 segue 的自定义类,但出现以下错误。我有另一个使用 Push 的 segue,效果很好。关于我做错了什么有什么想法吗?

这是我的课:

- (void) perform {

    UIViewController *src = (UIViewController *) self.sourceViewController;
    UIViewController *dst = (UIViewController *) self.destinationViewController;

    [UIView transitionWithView:src.navigationController.view duration:0.8
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    animations:^{
                        [src.navigationController pushViewController:dst animated:NO];
                    }
                    completion:NULL];

}

错误:

2012-02-20 16:04:45.889 IdeaStarters[2755:fe03] -[__NSCFDictionary setView:]: unrecognized selector sent to instance 0x6a40010
2012-02-20 16:04:45.891 IdeaStarters[2755:fe03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setView:]: unrecognized selector sent to instance 0x6a40010'
*** First throw call stack:
(0x13ba052 0x154bd0a 0x13bbced 0x1320f00 0x1320ce2 0x4fc3e 0x922f40 0x922eeb 0x50268 0x93dd60 0x3f8c54 0x3f8c8f 0x13bbe1a 0x1325821 0x22f46e 0xd6e2c 0xd73a9 0xd75cb 0xd7941 0xe947d 0xe966f 0xe993b 0xea3df 0xea561 0x2064ca 0x50301 0x13bbe72 0x1d6492d 0x1d6e827 0x1cf4fa7 0x1cf6ea6 0x1cf6580 0x138e9ce 0x1325670 0x12f14f6 0x12f0db4 0x12f0ccb 0x12a3879 0x12a393e 0x11a9b 0x2abd 0x2a25 0x1)
terminate called throwing an exception(lldb) 

最佳答案

您可能会发现始终设置此符号断点很有帮助。

https://github.com/brennanMKE/Interfaces/blob/master/NSAssertBreakpoint.png

该断点将自动停止调试器,让您有机会返回调用堆栈以查看问题的起点。

我经常在调用任何东西之前使用 NSAssert 来验证状态。

NSAssert([segue.destinationViewController isKindOfClass:[ABExpectedClass class]], @"Destination VC must be ABExpectedClass");

我记得有过这样的问题,但它试图调用的选择器不在我的代码中,通常调用 nil 值应该不是问题。我只是做错了什么,我使用的断言帮助我纠正了逻辑。

尝试在 GitHub 上查看其他自定义转场。有很多可供您引用。

https://github.com/search?q=UIStoryboardSegue&ref=commandbar

关于ios - 自定义 Segue 动画不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9368459/

相关文章:

ios - Swift 中的向上滑动动画

ios - 尝试添加 UIImage 作为 Storyboard中的背景(不重叠我的其他 ViewController 元素)

swift - Xcode:将对象与 View Controller 边距对齐

ios - 使用 prepareForSegue 在 View Controller 之间传递数据

ios - 即使 macOS 应用程序已使用开发者 ID 签名,Safari 也会要求允许未签名的扩展

ios - iOS 上 MeCab 日语分词器的选项?

html - CSS @keyframes 动画不透明度有效但最后回滚

android - 当 FAB 重力处于底部时,Circular Reveal 不起作用

ios - 从 Appstore 更新后运行 iOS 应用程序会发生什么情况?

ios - Django 在上传后旋转 iphone 图片