The collapse of UITableView's scrollToRowAtIndexPath:atScrollPosition:animated
[Abstract: Reason: '-[uitableview _contentoffsetforscrollingtorowatindexpath:atscrollposition:]: Row (0) beyond bounds (0) For section (0). The problem is that the Indexpath has crossed the border. Need to be diverted before the scene of the discriminant statement, not affect the function of the situation]
Reason: '-[uitableview _contentoffsetforscrollingtorowatindexpath:atscrollposition:]: Row (0) beyond bounds (0) for Section (0).
The error is that the incoming Indexpath has crossed the border. You need to add a judgment statement before the call, without compromising performance, before invoking the Reloaddate
code example:
@implementationUITableView (Scrolltotoporbottom)-(void) scrolltotopwithanimated: (BOOL) animated{if([selfnumberofsections]>0&&[selfnumberofrowsinsection:0]>0) {[Selfscrolltorowatindexpath: [Nsindexpathindexpathforrow:0insection:0]atscrollposition:uitableviewscrollpositiontopanimated:animated]; }}-(void) scrolltobottomwithanimated: (BOOL) animated{if([selfnumberofsections]>0) {Nsintegerlastsectionindex=[selfnumberofsections]-1; Nsintegerlastrowindex=[selfnumberofrowsinsection:lastsectionindex]-1; if(lastrowindex>0) {Nsindexpath*lastindexpath=[NSIndexPathindexPathForRow:lastRowIndexinSection:lastSectionIndex]; [selfscrollToRowAtIndexPath:lastIndexPathatScrollPosition:UITableViewScrollPositionBottomanimated:animated]; } }}@end
The collapse of UITableView's scrollToRowAtIndexPath:atScrollPosition:animated