首页 > 解决方案 > 在Objective C中推送segue时出现无法识别的选择器错误

问题描述

我有一个应用程序,它有一个侧边栏菜单(一个 UITableView),其中不同的行通过(推送)Segue 与主视图控制器单独连接。

只有其中一个不起作用,所以当我点击它时,我会收到以下消息:

****由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[MainTabBarController topViewController]:无法识别的选择器发送到实例 0x14880ce00”以未捕获的 NSException 类型异常终止*

在 SideBarViewController 中,这是导致崩溃的代码部分:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"[segue identifier]: %@",[segue identifier]);

if ([[segue identifier] isEqualToString:@"sync"]) {
    MainViewController *mainViewSync= (MainViewController *)[[segue destinationViewController] topViewController];
    mainViewSync.sync = 1;
}}

我该如何解决?

标签: iosobjective-cxcodesegueunrecognized-selector

解决方案


推荐阅读