iOS 8 Auto height cell not correct height at first load

前端 未结 5 1524
遥遥无期
遥遥无期 2020-12-28 15:54

I have an iOS 8 application where I have a search results page that each cell is autosized based on the height of a certain label. However, after the view first loads the c

5条回答
  •  甜味超标
    2020-12-28 16:23

    Yes, I've seen this same problem when making the views and constraints in the storyboard (but not with code added views). Iv'e fixed this by adding this code in the custom cell class,

    -(void)didMoveToSuperview { 
        [self layoutIfNeeded];
    }
    

    This could probably go other places, but this method seems to be called only once, so I thought it was a good place to do it.

提交回复
热议问题