【发布时间】:2014-03-02 13:59:42
【问题描述】:
这是导致问题的方法:
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TableCell";
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
// Configure the cell...
int row = [indexPath row];
Books *book = [myBooks objectAtIndex:row];
cell.bookName.text = book.bookName;
return cell;
}
完整日志:
2014-02-05 23:19:09.458 Books[1425:a0b] *** 断言失败 -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:5251
2014-02-05 23:19:09.471 Books[1425:a0b] *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法使具有标识符 TableCell 的单元格出列 - 必须为标识符或连接故事板中的原型单元'
*** 首先抛出调用堆栈:
(
0 核心基础 0x017395e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bc8b6 objc_exception_throw + 44
2 CoreFoundation 0x01739448 + [NSException raise:format:arguments:] + 136
3 基础 0x0109d23e -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 UIKit 0x003135e3-[UITableView dequeueReusableCellWithIdentifier:forIndexPath:] + 170
5 本书 0x000032df -[TableViewController tableView:cellForRowAtIndexPath:] + 127
6 UIKit 0x0031dd2f-[UITableView _createPreparedCellForGlobalRow:withIndexPath:] + 412
7 UIKit 0x0031de03-[UITableView _createPreparedCellForGlobalRow:] + 69
8 UIKit 0x00302124-[UITableView _updateVisibleCellsNow:] + 2378
9 UIKit 0x003155a5-[UITableView layoutSubviews] + 213
10 UIKit 0x00299dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
11 libobjc.A.dylib 0x014ce81f -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x03af372a -[CALayer layoutSublayers] + 148
13 石英核心 0x03ae7514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
14 QuartzCore 0x03af3675 -[CALayer layoutIfNeeded] + 160
15 UIKit 0x00354ca3-[UIViewController 窗口:setupWithInterfaceOrientation:] + 304
16 UIKit 0x00273d27-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 5212
17 UIKit 0x002728c6-[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
18 UIKit 0x00272798-[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
19 UIKit 0x00272820-[UIWindow _setRotatableViewOrientation:duration:force:] + 67
20 UIKit 0x002718ba __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
21 UIKit 0x0027181c-[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
22 UIKit 0x00272573-[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
23 UIKit 0x00275b66-[UIWindow setDelegate:] + 449
24 UIKit 0x00346dc7 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
25 UIKit 0x0026b7cc -[UIWindow addRootViewControllerViewIfPossible] + 609
26 UIKit 0x0026b947 -[UIWindow _setHidden:forced:] + 312
27 UIKit 0x0026bbdd-[UIWindow_orderFrontWithoutMakingKey] + 49
28 UIKit 0x0027644a -[UIWindow makeKeyAndVisible] + 65
29 UIKit 0x002298e0-[UIApplication_callInitializationDelegatesForURL:payload:suspended:] + 1851
30 UIKit 0x0022dfb8-[UIApplication_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
31 UIKit 0x0024242c-[UIApplication 句柄事件:withNewEvent:] + 3447
32 UIKit 0x00242999 -[UIApplication 发送事件:] + 85
33 UIKit 0x0022fc35 _UIApplicationHandleEvent + 736
34 图形服务 0x0368c2eb _PurpleEventCallback + 776
35 图形服务 0x0368bdf6 PurpleEventCallback + 46
36 核心基础 0x016b4dd5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
37 核心基础 0x016b4b0b __CFRunLoopDoSource1 + 523
38 核心基础 0x016df7ec __CFRunLoopRun + 2156
39 核心基础 0x016deb33 CFRunLoopRunSpecific + 467
40 核心基础 0x016de94b CFRunLoopRunInMode + 123
41 UIKit 0x0022d6ed-[UIApplication_run] + 840
42 UIKit 0x0022f94b UIApplicationMain + 1225
43 本书 0x000038bd 主要 + 141
44 libdyld.dylib 0x01d75725 开始 + 0
45 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib:以 NSException 类型的未捕获异常终止
(lldb)
【问题讨论】:
-
你不会在表格视图中初始化单元格,分配你的单元格,见@gago ans
标签: ios objective-c uitableview