[摘要:reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (0) beyond bounds (0) for section (0). 那个毛病是传进的IndexPath已越界了。需要正在挪用以前到场判别语句,没有影响机能的情] 性能
reason: '-[UITableView _contentOffsetForScrollingToRowAtIndexPath:atScrollPosition:]: row (0) beyond bounds (0) for section (0).spa
这个错误是传入的IndexPath已经越界了。须要在调用以前加入判断语句,不影响性能的状况下,在调用以前要先reloadDatecode
代码示例:blog
@implementation UITableView(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