• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

iphone - viewWillAppear 时 ECSlidingViewController 错误(对象不能为 nil)

[复制链接]
菜鸟教程小白 发表于 2022-12-12 14:59:01 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

在我的应用程序中,我有一个导航 Controller ,它连接到另一个 viewController(根 Controller )。在我的项目中,我导入了 ECSlidingViewController.h 和 .m。在将用作右侧菜单 (listViewController.h) 的 viewController 中,我导入了 ECSlidingViewController.h 并在 viewDidLoad 中这样做了:

[super viewDidLoad];
    self.peekLeftAmount = 40.0f;
    [self.slidingViewController setAnchorLeftPeekAmount:self.peekLeftAmount];
    self.slidingViewController.underRightWidthLayout = ECVariableRevealWidth;

在 navigationController 类中,我这样做了(在导入 ECSlidingViewController.h 和 listViewController.h 之后):

- (void)viewWillAppearBOOL)animated
{
    [super viewWillAppear:animated];

    if (![self.slidingViewController.underRightViewController isKindOfClass:[ListViewController class]]) {
        self.slidingViewController.underRightViewController  = [self.storyboard instantiateViewControllerWithIdentifier"ListStore"];
    }

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}

但是当我运行应用程序时,当我到达代码行 [self.view addGestureRecognizer:self.slidingViewController.panGesture]; 应用程序崩溃,并给我以下错误:

2013-09-28 01:59:55.629 Myapp[2627:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(
    0   CoreFoundation                      0x024595e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x01a6f8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x0240bc3c -[__NSArrayM insertObject:atIndex:] + 844
    3   CoreFoundation                      0x0240b8e0 -[__NSArrayM addObject:] + 64
    4   UIKit                               0x0063f497 -[UIView(UIViewGestures) addGestureRecognizer:] + 208
    5   Myapp                              0x0001a934 -[MainNavigationController viewWillAppear:] + 564
    6   UIKit                               0x006ec28a -[UIViewController _setViewAppearState:isAnimating:] + 419
    7   UIKit                               0x006ec798 -[UIViewController __viewWillAppear:] + 114
    8   UIKit                               0x006fd310 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 199
    9   UIKit                               0x0097d627 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 6236
    10  UIKit                               0x006f478c -[UIViewController presentViewController:withTransition:completion:] + 6433
    11  UIKit                               0x006f4caf -[UIViewController presentViewController:animated:completion:] + 130
    12  Myapp                              0x00017447 -[SplashScreenViewController viewDidAppear:] + 839
    13  UIKit                               0x006ec2d8 -[UIViewController _setViewAppearState:isAnimating:] + 497
    14  UIKit                               0x006ec867 -[UIViewController __viewDidAppear:] + 146
    15  UIKit                               0x006ee22f __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44
    16  UIKit                               0x006ecbfa -[UIViewController _executeAfterAppearanceBlock] + 63
    17  UIKit                               0x005f1d59 ___afterCACommitHandler_block_invoke_2 + 33
    18  UIKit                               0x005f1cde _applyBlockToCFArrayCopiedToStack + 403
    19  UIKit                               0x005f1b2e _afterCACommitHandler + 568
    20  CoreFoundation                      0x0242153e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    21  CoreFoundation                      0x0242148f __CFRunLoopDoObservers + 399
    22  CoreFoundation                      0x023ff3b4 __CFRunLoopRun + 1076
    23  CoreFoundation                      0x023feb33 CFRunLoopRunSpecific + 467
    24  CoreFoundation                      0x023fe94b CFRunLoopRunInMode + 123
    25  GraphicsServices                    0x032da9d7 GSEventRunModal + 192
    26  GraphicsServices                    0x032da7fe GSEventRun + 104
    27  UIKit                               0x005d594b UIApplicationMain + 1225
    28  Myapp                              0x00002b2b main + 235
    29  libdyld.dylib                       0x01f54725 start + 0
    30  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

请帮帮我!



Best Answer-推荐答案


UIStoryboard *storyBoard = [UIStoryboard storyboardWithName"Main_iPhone" bundle:nil];
UIViewController *MainView = [storyBoard instantiateViewControllerWithIdentifier"MyMailBox"];
self.slidingViewController.topViewController = MainView;

关于iphone - viewWillAppear 时 ECSlidingViewController 错误(对象不能为 nil),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19062032/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap