【发布时间】:2011-11-29 12:59:44
【问题描述】:
我正在尝试做一个“项目列表”->“项目详细信息”类型的应用程序。 到目前为止,我已经成功地完成了列表部分。我还为项目详细信息创建了一个新视图,但是当我单击要查看详细信息的项目时出现错误。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
ItemDetailsView *detailViewController = [[ItemDetailsView alloc] initWithNibName:@"DetailView" bundle:[NSBundle mainBundle]];
// ERROR HERE
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
到目前为止,新视图只有一个空标签,上面写着“视图已更改:确定”。没有别的了。
ItemDetailsView 是继承自 UIViewController 的视图。
为了创建这个视图,我进入了 New File -> Cocoa Touch -> UIViewController 子类。
当我尝试执行下面的行时,我得到的错误是“signabrt” //ERROR HERE
下面是完整的消息:
2011-10-02 17:26:03.582 Teste Data Nav[10035:b303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/leo/Library/Application Support/iPhone Simulator/4.3.2/Applications/FA60D1E7-1B98-4943-98AA-C86A2339AC3E/Teste Data Nav.app> (loaded)' with name 'DetailView''
*** 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 0x0020f0fa -[UINib instantiateWithOwner:options:] + 2024
5 UIKit 0x00210ab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
6 UIKit 0x000c6628 -[UIViewController _loadViewFromNibNamed:bundle:] + 70
7 UIKit 0x000c4134 -[UIViewController loadView] + 120
8 UIKit 0x000c400e -[UIViewController view] + 56
9 UIKit 0x000c2482 -[UIViewController contentScrollView] + 42
10 UIKit 0x000d2f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
11 UIKit 0x000d1555 -[UINavigationController _layoutViewController:] + 43
12 UIKit 0x000d27aa -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
13 UIKit 0x000cd32a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
14 UIKit 0x000d4562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932
15 UIKit 0x000cd1c4 -[UINavigationController pushViewController:animated:] + 62
16 Teste Data Nav 0x00002d4c -[RootViewController tableView:didSelectRowAtIndexPath:] + 220
17 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
18 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
19 Foundation 0x0079b79e __NSFireDelayedPerform + 441
20 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
21 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
22 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
23 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
24 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
25 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
26 GraphicsServices 0x00ffa289 GSEventRun + 115
27 UIKit 0x00022c93 UIApplicationMain + 1160
28 Teste Data Nav 0x000023b9 main + 121
29 Teste Data Nav 0x00002335 start + 53
)
terminate called throwing an exceptionCurrent language: auto; currently objective-c
【问题讨论】:
-
你在 IB 或其他地方正确分配了 UINavigationController 吗?
-
我还没有分配 UINavigationController...
-
既然你使用 nib 文件,我想你应该至少在 IB 中定义一个。
标签: objective-c ios uiviewcontroller pushviewcontroller