以下是在UINavigationalController上请求代码的错误
2013-11-02 09:30:33.727 NavigationalCntrlApp[465:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing a navigation controller is not supported'
*** First throw call stack:
(
0 CoreFoundation 0x0173a5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bd8b6 objc_exception_throw + 44
2 UIKit 0x003676bd __71-[UINavigationController pushViewController:transition:forceImmediate:]_block_invoke + 0
3 UIKit 0x003670b5 -[UINavigationController pushViewController:animated:] + 325
4 UIKit 0x003557d7 -[UINavigationController initWithRootViewController:] + 122
5 NavigationalCntrlApp 0x00002c91 -[AppDelegate application:didFinishLaunchingWithOptions:] + 673
6 UIKit 0x00225355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
7 UIKit 0x00225b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
8 UIKit 0x0022a3a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
9 UIKit 0x0023e87c -[UIApplication handleEvent:withNewEvent:] + 3447
10 UIKit 0x0023ede9 -[UIApplication sendEvent:] + 85
11 UIKit 0x0022c025 _UIApplicationHandleEvent + 736
12 GraphicsServices 0x036e12f6 _PurpleEventCallback + 776
13 GraphicsServices 0x036e0e01 PurpleEventCallback + 46
14 CoreFoundation 0x016b5d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
15 CoreFoundation 0x016b5a9b __CFRunLoopDoSource1 + 523
16 CoreFoundation 0x016e077c __CFRunLoopRun + 2156
17 CoreFoundation 0x016dfac3 CFRunLoopRunSpecific + 467
18 CoreFoundation 0x016df8db CFRunLoopRunInMode + 123
19 UIKit 0x00229add -[UIApplication _run] + 840
20 UIKit 0x0022bd3b UIApplicationMain + 1225
21 NavigationalCntrlApp 0x0000304d main + 141
22 libdyld.dylib 0x01d7870d start + 1
23 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
任何人都可以帮助我为什么会出现这个错误,在Xcode 4.3中使用相同的代码,但它在Xcode 5中引发了错误。
答案 0 :(得分:0)
看起来您尝试将navigationController设置为navigationController的rootviewcontroller。这是不允许的
如果我是对的,你就是这样做的:
// 1. Make new UIViewController
UIViewController *vc = [[UIViewController alloc] init];
// 2. Make UINavigationController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
// 3. Set navigationController as rootViewController of a new navigationController
UINavigationController *nav2 = [[UINavigationController alloc] initWithRootViewController:nav];
虽然你应该这样做:
// 1. Make New UIViewController
UIViewController *vc = [[UIViewController alloc] init];
// 2. Set it as rootviewcontroller of a new navigationController
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[self.navigationController pushViewController:nav];
如果我的问题出错,请在您的问题中发布一些额外的代码。