Terminating app due to uncaught exception CALayerInvalidGeom

小胖说事35—–Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer posi

分类:IOS开发

***Callstackatfirstthrow:()terminatecalledafterthrowinganinstanceof’NSException

某天,,加完一个功能,在iPhone4上报以上异常,然后crash掉,iPhone3上没事。百思不得其解,于是google之。看了一篇stackoverflow.com的文章,说是某些地方代码除以0了,多见于自定义的UITableView自定义UITableViewCell高度的地方,如:tableView:heightForHeaderInSection:或tableView:heightForFooterInSection:。这两个delegate方法都没有地方需要除的。在仔细看一下文章,说多见于适用sizeWithFont方法计算UILabel宽高的地方。恍然大悟,小弟有一个地方使用了UILabel来显示文本,需要用到sizeWithFont方法计算宽高的,在NSString为nil的时候,sizeWithFont会除以0了。

PS:在使用sizeWithFont计算UItabelView中label中字的长度时,由于表视图的cell是复用的,所以在计算label中的NSString的长度时,NSString可能为nil,此时可能会除以0,便会报错。

版权声明:本文为博主原创文章,未经博主允许不得转载。

上一篇小胖学PHP总结5—–PHP操作SQL数据库(Deprecated: mysql_connect(): The mysql extension is deprecated and will)

顶1踩0

轻轻的风,吹开你紧锁的眉头,

Terminating app due to uncaught exception CALayerInvalidGeom

相关文章:

你感兴趣的文章:

标签云: