2011-04-13 87 views
0

当我通过调用handleSearchTerm子例程的TextDidChange在TableView上搜索时,它完美的工作。但是,我删除了TextDidChange并使用SearchButtonClicked来更新tableView(使用相同的子例程),但它并没有正确更新TableView,并且在滚动时(cellForRowAtIndex中的绑定索引超出限制)崩溃,即使数据源已在子例程中更改。任何想法?iphone在搜索问题后更新tableview

[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' 

回答

1

我认为暴跌是由引起的cellForRowAtIndexPath,你可以请张贴代码如下方法:

cellForRowAtIndexPath 
SearchButtonClicked 
yourSubroutine you are calling 

也提到你的arraycollection从中加载你的表。

感谢,

+0

多数民众赞成在正确的,我知道哪里崩溃,我知道它崩溃的原因。我的意思是,searchBarSearchButtonClicked和TextDidChange使用相同的子程序,但结果不同。 – 2011-04-13 03:13:42

+0

你只是在这些方法中调用这个例程,你没有做任何其他的事情吗?意思-SearchButtonClicked(){yourroutine(); //没有其他的东西} – Ravin 2011-04-13 03:17:32

+0

@Ravin从搜索栏中获取文本并将其传递给子例程即全部 – 2011-04-13 03:18:44

0

按你的崩溃日志,看来你是在你重新调整错误的细胞没有noOfcellsInsection方法。你正在得到数组超出界限的错误。当你正在做搜索时,使一个标志为真,根据该标志,使用你过滤的数组的数量返回表视图的行数。