What causes this error? “CALayer position contains NaN: [240 nan]”

前端 未结 7 1681
星月不相逢
星月不相逢 2020-12-08 00:41

I\'ve seen this happen whenever i rotate a screen that has a UITableView on it. I\'ve found out that it happens inbetween the willRotate and

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-08 01:07

    I've found the problem.

    When you reset the frame of a tableview, it calls the delegate method tableView:heightForRowAtIndexPath: for each row in the table so it can recalculate its content size if it needs to. At that point, we do some special handling to return the height, and due to some bad assumptions in our code, we mistakenly returned NaN due to a divide by zero error (the variable we divide by was assumed to never be zero). Making sure that we do not divide by zero here fixed it.

提交回复
热议问题