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

时间:2015-02-06 14:30:56

标签: ios xcode uiviewcontroller slider

好的,我真的很难通过所有关于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帖子两天之后,我才得到它...

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

1 个答案:

答案 0 :(得分:0)

确定。事实证明我的代码完全没有问题,我的问题的解决方案是我之前没有看过的,所以我会在这里发布:

我使用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 ...),并且在另一行上继承$并且它们可以一起工作。只需记住清理你的构建并擦除模拟器(甚至可能重新启动Xcode)并再次构建。