2

我有一个为自定义 segue 动画编写的自定义类。我正在尝试自定义点击手势的动画。在我的故事板中,我有一个导航控制器、主视图和另外两个视图。我已将手势连接到另一个视图,并定义了 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) 
4

1 回答 1

1

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

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

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

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

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

我记得遇到过这样的问题,但它试图调用的选择器不是来自我的代码内部,通常在 nil 值上调用某些东西应该不是问题。我只是做错了什么,我使用的断言帮助我纠正了逻辑。

尝试在 GitHub 上查看其他自定义 segue。有很多可以作为参考。

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

于 2012-12-30T03:57:43.553 回答