The collapse of UITableView's scrollToRowAtIndexPath:atScrollPosition:animated

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.