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