在我的应用程序中,我有一个导航 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-推荐答案 strong>
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/
|