這種錯誤是在float類型經過函數運行后,出現了不為數字的值,
nan的意思就是not a number
诈泼。
主要常見原因:
- 除以0
- sizeWithFont的字符串為nil
- 數學函數不正確運算
解決方法除了排除根源所在之外紊遵,用函數isnan()也是不錯的選擇(至少在沒有徹底解決以前)
如下
float _x = NAN;
if (!isnan(_x)) {
cell.imgView.frame = CGRectMake(_x, 8, 10, 12);
}”
CGFloat adScale = newsData.FHEIGHT / newsData.FWIDTH;
if (isnan(adScale)) {
adScale = 0;
}