开发者

iphone updating tableview after searching issue

When I search on TableView through TextDidChange which calls handleSearchTerm subroutine, it perfectly works. However, I removed TextDidChange and use SearchButtonClicked to update tableView (use same subroutine),it doesn't update TableView properly and crash when scroll(out of bound index in cellForRowAtIndex) even though datasource has been changed in subroutine. Any idea?

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


I think crash is caused by cellForRowAtIndexPath, can you please post code for following methods :

cellForRowAtIndexPath
SearchButtonClicked
yourSubroutine you are calling

also mention your array or collection from which you are loading your table.

Thanks,


as per your crash log it seems you are retuning wrong no of cells in you noOfcellsInsection method. You are getting array out of bounds error.When you are doing search make a flag true and according to that flag return no of rows for the table view using your filtered array's count.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜