IOS development: the positions of the tableview are disordered and the offset is returned to the original position, iostableview

Source: Internet
Author: User

IOS development: the positions of the tableview are disordered and the offset is returned to the original position, iostableview

Why is the data location disordered when I pull it up and refresh it? Is the table view offset incorrect? For example, a total of 40 data records and 20 data records are loaded at a time. Normally, 21st data records are displayed. After loading the data, we find that the tableview stops at 11th or 30 data records, if you are experiencing the same situation as me

-(Void) addRefresh {__ weak typeof (self) weakSelf = self; weakSelf. nomalTable. mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock: ^ {weakSelf. page = @ "0"; [weakSelf tableReloadCtrlWithPage] ;}]; weakSelf. nomalTable. mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingBlock: ^ {NSInteger index = [self. page intValue]; index + = 1; weakSelf. page = [NSString stringWithFormat: @ "% ld", (long) inde X]; [weakSelf tableReloadCtrlWithPage] ;}]; [weakSelf. nomalTable. mj_header beginRefreshing];} // the page here refers to the page number. // when it is set to if page = 1 else page + = 1-(void) tableReloadCtrlWithPage {[self. nomalTable reloadData]; if (! Self. dataArr. count? YES: NO) {self. nomalTable. tableFooterView = [self getTableFootView: self. nomalTable. bounds str: @ "nodata"];} else {self. nomalTable. tableFooterView = [UIView new];} NSInteger oldCnt = [self. dataArr count]; if (oldCnt> 0 & [self. page intValue]! = 0) {NSInteger row = oldCnt-20; NSIndexPath * indexPath = [NSIndexPath indexPathForRow: row inSection: 0]; [self. nomalTable scrollToRowAtIndexPath: indexPath atScrollPosition: UITableViewScrollPositionBottom animated: NO] ;}}

Related Article

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.