- 我在Fabric crashalytics中遇到此错误。
- 显示为编译器生成的错误。
- 我已经尝试了很多方法来解决它,但是没有用。
- 我需要帮助。我是开发中的新手。
“我已经尝试了许多方案来重现错误,例如重新加载数据并旋转设备,但它在我的设备iphone 6上正常运行,但是在客户端iphone XR上崩溃了。”
Crashed: com.apple.main-thread
0 WorkInProgress 0x10471dc58 specialized
WIPInsightNewVC.collectionView(_:layout:sizeForItemAt:) (<compiler-
generated>)
1 WorkInProgress 0x104713390 @objc
WIPInsightNewVC.collectionView(_:layout:sizeForItemAt:) (<compiler-
generated>)
2 UIKitCore 0x1be82c200 -
[UICollectionViewFlowLayout
_getSizingInfosWithExistingSizingDictionary:] + 2976
3 (Missing) 0x4a655d81be82d800 (Missing)
4 (Missing) 0x0 (Missing)
5 (Missing) 0x741c9081be820800 (Missing)
6 (Missing) 0x791e1b01be821000 (Missing)
7 (Missing) 0x7516ca81be7f1c00 (Missing)
8 (Missing) 0x0 (Missing)
9 (Missing) 0x1b2e2401bac27b00 (Missing)
10 (Missing) 0x1674481c19ee0f0 (Missing)
11 (Missing) 0x0 (Missing)
12 (Missing) 0x0 (Missing)
13 (Missing) 0x3311a201c1946c00 (Missing)
14 (Missing) 0xa4c0701c1971c00 (Missing)
15 (Missing) 0x414a1f81c1972800 (Missing)
16 (Missing) 0x0 (Missing)
17 (Missing) 0x0 (Missing)
18 (Missing) 0x4b0edd81bae87800 (Missing)
19 (Missing) 0x597e0b01bae87000 (Missing)
20 (Missing) 0x0 (Missing)
21 (Missing) 0x0 (Missing)
22 (Missing) 0x0 (Missing)
23 libdyld.dylib 0x1bad06f30 start + 4
sizeForItemAt方法中的代码,可能会帮助您解决我的问题。
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
var width = view.frame.width - 40
let height = UIScreen.main.bounds.height
var estimatedFrame = CGRect()
var size = CGSize()
size = CGSize(width: width, height: .greatestFiniteMagnitude)
if collectionView == progressCV {
let obj = (appDel?.objActiveUserTaskProgress?.workProgressRecords?[indexPath.row])!
estimatedFrame = NSAttributedString(attributedString: obj.pROGRESSTASKDESCRIPTION.htmlAttributedString()!).boundingRect(with: size, options: .usesLineFragmentOrigin, context: nil)
sizes = Int(estimatedFrame.height)
}
else {
let obj = (appDel?.objActiveUserTaskProgress?.graphDetails?[indexPath.row])!
estimatedFrame = NSAttributedString(attributedString: obj.pROGRESSTASKDESCRIPTION.htmlAttributedString()!).boundingRect(with: size, options: .usesLineFragmentOrigin, context: nil)
sizes = Int(estimatedFrame.height)
}
print(sizes)
if sizes <= 20 {
sizes = 25
}
sizes += 64
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
width = progressCV.bounds.width / 2 - 15
return CGSize(width: Int(width), height: sizes)
}
else {
if iphoneX {
if width > height {
width = progressCV.bounds.width
}
}
return CGSize(width: Int(width), height: sizes)
}
}
答案 0 :(得分:0)
在iOS 13中,每当您隐藏(或)取消隐藏视图时,为高度限制赋予常数值,并且所有操作都只能在主线程中完成。
例如:
DispatchQueue.main.async {
self.heightConstraint.constant = 150
self.listView.isHidden = true
}