PKReveal 控制器 UIVIEW 无法识别的选择器发送到实例

PKReveal Controller UIVIEW unrecognized selector sent to instance

好的,我真的很努力地浏览了所有其他关于 PKRevealController 的帖子并弄清楚了这一点……但到目前为止还没有发生。所以这就是我得到的:

AppDelegate.m

    ViewController *viewController = (ViewController *)self.window.rootViewController;

    UIViewController *leftViewController = [[UIViewController alloc] init];

    leftViewController.view.backgroundColor = [UIColor redColor];

    PKRevealController *revealController = [PKRevealController revealControllerWithFrontViewController:viewController rightViewController:leftViewController];

    self.window.rootViewController = revealController;

我的主视图就叫ViewController。我只想让左滑动工作。也许我只是对它应该做什么感到困惑......但它给了我这个错误:

2015-02-06 14:02:40.810 bibi[5421:90b] (null)
2015-02-06 14:02:41.823 bibi[5421:90b] -[UIViewController setRevealController:]: unrecognized selector sent to instance 0xcd7c9f0
2015-02-06 14:02:41.870 bibi[5421:90b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController setRevealController:]: unrecognized selector sent to instance 0xcd7c9f0'


    *** First throw call stack:
(
    0   CoreFoundation                      0x02e181e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x02b978e5 objc_exception_throw + 44
    2   CoreFoundation                      0x02eb5243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x02e0850b ___forwarding___ + 1019
    4   CoreFoundation                      0x02e080ee _CF_forwarding_prep_0 + 14
    5   bibi                                0x00007f55 -[PKRevealController initWithFrontViewController:leftViewController:rightViewController:options:] + 357
    6   bibi                                0x00007d59 -[PKRevealController initWithFrontViewController:rightViewController:options:] + 185
    7   bibi                                0x00007afc +[PKRevealController revealControllerWithFrontViewController:rightViewController:] + 188
    8   bibi                                0x0001fa61 -[AppDelegate redirect] + 321
    9   Foundation                          0x025c05ec __NSFireDelayedPerform + 372
    10  CoreFoundation                      0x02dd6ac6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    11  CoreFoundation                      0x02dd64ad __CFRunLoopDoTimer + 1181
    12  CoreFoundation                      0x02dbe538 __CFRunLoopRun + 1816
    13  CoreFoundation                      0x02dbd9d3 CFRunLoopRunSpecific + 467
    14  CoreFoundation                      0x02dbd7eb CFRunLoopRunInMode + 123
    15  GraphicsServices                    0x04de85ee GSEventRunModal + 192
    16  GraphicsServices                    0x04de842b GSEventRun + 104
    17  UIKit                               0x0164af9b UIApplicationMain + 1225
    18  bibi                                0x000eea3d main + 141
    19  libdyld.dylib                       0x0335f725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我确定我只是想念它是一些简单而愚蠢的东西。但是天气很冷,我感冒了,在尝试并阅读了两天的所有 SO 帖子后我就是不明白...

编辑: 如果有帮助,添加了完整的日志。

好的。事实证明我的代码绝对没有问题,我的问题的解决方案是我以前从未见过的 posted 所以我会 post 在这里:

我使用 Cocoapods 安装了 PKRevealController,但安装并没有真正成功地给我错误:

Debug is overwriting the Build Settings for "HEADER_LINK_PATH"
Debug is overwriting the Build Settings for "OTHER_LD_FLAGS"

我在构建设置中加载了 libsql 和 ObjC 以及其他一些东西,但我没有继承 PKRevealController 的 Pod 设置。

删除 ObjC 并在这些路径中使用“$inherited”有助于加载 PKRevealController,此后程序运行良好。正如任何遇到此问题的人注意的那样,您可以在一行上加载您想要的设置(在我的例子中是 libsql ...)并在另一行上加载 $inherited,它们将一起工作得很好。请记住清理您的构建并擦除模拟器(甚至可能重新启动 Xcode)并再次构建。