搜索问题后iphone更新tableview

时间:2011-04-13 02:39:11

标签: iphone objective-c

当我通过调用handleSearchTerm子例程的TextDidChange搜索TableView时,它完全有效。但是,我删除了TextDidChange并使用SearchButtonClicked来更新tableView(使用相同的子例程),它不会正确更新TableView并在滚动时出现崩溃(在cellForRowAtIndex中超出绑定索引),即使数据源已在子例程中更改。任何的想法?

[78515:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (8) beyond bounds (8)'
*** Call stack at first throw:  
(
0   CoreFoundation                      0x00db8be9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x00f0d5c2 objc_exception_throw + 47
2   CoreFoundation                      0x00d71628 +[NSException raise:format:arguments:] + 136
3   CoreFoundation                      0x00d7159a +[NSException raise:format:] + 58
4   CoreFoundation                      0x00dae8c9 _NSArrayRaiseBoundException + 121
5   CoreFoundation                      0x00db0027 -[__NSCFArray objectAtIndex:] + 87
6   DrinkGuide_v1.0                     0x00005d6c -[AllDrinkTableViewController tableView:cellForRowAtIndexPath:] + 371
7   UIKit                               0x003357fa -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 634
8   UIKit                               0x0032b77f -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:] + 75
9   UIKit                               0x00340450 -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1561
10  UIKit                               0x00338538 -[UITableView layoutSubviews] + 242
11  QuartzCore                          0x01c76451 -[CALayer layoutSublayers] + 181
12  QuartzCore                          0x01c7617c CALayerLayoutIfNeeded + 220
13  QuartzCore                          0x01c6f37c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
14  QuartzCore                          0x01c6f0d0 _ZN2CA11Transaction6commitEv + 292
15  QuartzCore                          0x01c9f7d5 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 99
16  CoreFoundation                      0x00d99fbb __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
17  CoreFoundation                      0x00d2f0e7 __CFRunLoopDoObservers + 295
18  CoreFoundation                      0x00cf7bd7 __CFRunLoopRun + 1575
19  CoreFoundation                      0x00cf7240 CFRunLoopRunSpecific + 208
20  CoreFoundation                      0x00cf7161 CFRunLoopRunInMode + 97
21  GraphicsServices                    0x016ed268 GSEventRunModal + 217
22  GraphicsServices                    0x016ed32d GSEventRun + 115
23  UIKit                               0x002d042e UIApplicationMain + 1160
24  DrinkGuide_v1.0                     0x0000298c main + 102
25  DrinkGuide_v1.0                     0x0000291d start + 53
)
terminate called after throwing an instance of 'NSException'

2 个答案:

答案 0 :(得分:1)

我认为崩溃是由cellForRowAtIndexPath引起的,请您发布以下方法的代码:

cellForRowAtIndexPath
SearchButtonClicked
yourSubroutine you are calling

还提及您要加载表格的arraycollection

谢谢,

答案 1 :(得分:0)

根据你的崩溃日志,似乎你在noOfcellsInsection方法中重新调整了错误的单元格。您正在进行数组越界错误。当您进行搜索时,将标志设为true并根据该标志使用过滤后的数组计数返回表视图的行数。