我创建了一个基于导航的应用程序。在第一个视图中显示饮料列表,在第二个视图中它显示了饮料的详细信息。 一切似乎还可以,但是当我在(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法导航视图时,它会显示错误,如
在抛出'NSException'实例后终止调用
在第
行 [self.navigationController pushViewController:drinkDetailViewController animated:YES];
请帮助我,为什么会这样?
我的方法代码如下:
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DrinkDetailViewController *drinkDetailViewController = [[DrinkDetailViewController alloc] initWithNibName:@"DrinkDetailViewController" bundle:nil];
//UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:drinkDetailViewController];
//[self presentModalViewController:drinkDetailViewController animated:YES];
//[self dismissModalViewControllerAnimated:YES];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:drinkDetailViewController animated:YES];
[drinkDetailViewController release];
}
当我点击行时,它会显示异常消息。 这是项目日志:
2011-08-10 10:18:10.559 DrinkMixer_Shreyash[694:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DrinkDetailViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00d7aef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7ae6a +[NSException raise:format:] + 58
4 UIKit 0x000c6709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x000c4134 -[UIViewController loadView] + 120
6 UIKit 0x000c400e -[UIViewController view] + 56
7 UIKit 0x000c2482 -[UIViewController contentScrollView] + 42
8 UIKit 0x000d2f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x000d1555 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x000d27aa -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
11 UIKit 0x000cd32a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x000d4562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x000cd1c4 -[UINavigationController pushViewController:animated:] + 62
14 DrinkMixer_Shreyash 0x000029bf -[RootViewController tableView:didSelectRowAtIndexPath:] + 191
15 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
16 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
17 Foundation 0x0079b79e __NSFireDelayedPerform + 441
18 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
19 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
20 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
21 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
23 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
24 GraphicsServices 0x00ffa289 GSEventRun + 115
25 UIKit 0x00022c93 UIApplicationMain + 1160
26 DrinkMixer_Shreyash 0x00002089 main + 121
27 DrinkMixer_Shreyash 0x00002005 start + 53
28 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
请帮我解决一下。 。 。
答案 0 :(得分:3)
iDroid Explorer,在您的饮料DetailViewController类中,您必须将视图变量连接到Xib文件的view元素。它必须通过界面构建器完成。
答案 1 :(得分:2)
这是关于您在DrinkDetailViewController中的IBOutlet for View未在XIB文件中设置的崩溃。请在XIB中设置您的视图,然后尝试运行该应用程序。这是使用Interface builder ..
完成的快乐编码......