iOS development--mjrefresh on pull-up loading, tableview will be offset upward

Source: Internet
Author: User

1, the cause of this situation:

This should be the biggest change in UITableView. We know that after the introduction of self-sizing in IOS8, we can show the dynamic content by implementing the Estimatedrowheight related properties, and when the Estimatedrowheight attribute is implemented, the initial contensize is an estimate. , is estimatedrowheight multiplied by the number of cells to get, not the final contensize, but the current screen can display the number of cells, sliding, tableview constantly get a new cell, update their contensize.

Self-sizing is enabled by default under IOS11, Headers, footers, and cells are all turned on by default self-sizing, all estimated height default values from iOS11 0 Change to Uitableviewautomaticdimension:

If the Estimaterowheight attribute is not used in the current project, it is important to be aware of it in the IOS11 environment, because TableView uses the Estimaterowheight attribute after the self-sizing is turned on. This will cause contentsize and contentoffset values to change, if the animation is to observe the changes of these two properties, it will cause animation anomalies, because in the estimation of the row height mechanism, the value of Contentsize is a little change update, The final contentsize value after all cells are displayed. Because the correct row height is not cached, the contentsize is recalculated when TableView reloaddata, which can cause contentoffset changes.

2, the solution, the code is as follows:

-(void) creatui{Communtablev= [[UITableView alloc]initwithframe:cgrectmake (0, Navheight, Kscreenw, kscreenh-navheight-bottomheight- -) Style:uitableviewstyleplain]; Communtablev.Delegate=Self ; Communtablev.datasource=Self ; Communtablev.tablefooterview=[[UIView alloc]init]; Communtablev.tableheaderview=[self THIRDV]; Communtablev.estimatedrowheight=0; Communtablev.estimatedsectionfooterheight=0; Communtablev.estimatedsectionheaderheight=0; if(@available (IOS11.0, *) ) {Communtablev.contentinsetadjustmentbehavior=Uiscrollviewcontentinsetadjustmentnever; } Else {        //Fallback on earlier versions}if(@available (IOS11.0, *) ) {Communtablev.contentinsetadjustmentbehavior=Uiscrollviewcontentinsetadjustmentnever; } Else {        //Fallback on earlier versions} [Self.view Addsubview:communtablev];}

Just do the record, don't ask me why the following judgment two times, is the warning points out!

iOS development--mjrefresh on pull-up loading, tableview will be offset upward

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.