Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 崩溃:com.apple.main-thread BasePostCell.collectionView(u3;:cellForItemAt:)_Ios_Swift_Uicollectionview - Fatal编程技术网

Ios 崩溃:com.apple.main-thread BasePostCell.collectionView(u3;:cellForItemAt:)

Ios 崩溃:com.apple.main-thread BasePostCell.collectionView(u3;:cellForItemAt:),ios,swift,uicollectionview,Ios,Swift,Uicollectionview,我从crashlytics公司撞车了,你能告诉我这是什么原因吗?它是连接到AuthManager还是BasePostCell Crashed: com.apple.main-thread 0 goForDream 0x1023f22ac BasePostCell.collectionView(_:cellForItemAt:) + 4304741036 (<compiler-generated>:4304741036) 1 goForDre

我从crashlytics公司撞车了,你能告诉我这是什么原因吗?它是连接到AuthManager还是BasePostCell

Crashed: com.apple.main-thread
0  goForDream                     0x1023f22ac BasePostCell.collectionView(_:cellForItemAt:) + 4304741036 (<compiler-generated>:4304741036)
1  goForDream                     0x1023f2340 @objc BasePostCell.collectionView(_:cellForItemAt:) + 4304741184 (<compiler-generated>:4304741184)
2  UIKitCore                      0x19ae22d00 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 444
3  UIKitCore                      0x19ae249c8 -[UICollectionView _prefetchItemsForPrefetchingContext:maxItemsToPrefetch:] + 476
4  UIKitCore                      0x19ae2c4fc -[UICollectionView layoutSubviews] + 1020
5  UIKitCore                      0x19baa48b0 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2156
6  libobjc.A.dylib                0x197204a4c -[NSObject performSelector:withObject:] + 68
7  QuartzCore                     0x19e0ba55c -[CALayer layoutSublayers] + 292
8  QuartzCore                     0x19e0ba9ac CA::Layer::layout_if_needed(CA::Transaction*) + 484
9  QuartzCore                     0x19e0cd1bc CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 140
10 QuartzCore                     0x19e011b00 CA::Context::commit_transaction(CA::Transaction*, double) + 308
11 QuartzCore                     0x19e03c910 CA::Transaction::commit() + 684
12 QuartzCore                     0x19e03d4e4 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 96
13 CoreFoundation                 0x19746b524 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
14 CoreFoundation                 0x1974661c4 __CFRunLoopDoObservers + 420
15 CoreFoundation                 0x197466774 __CFRunLoopRun + 1292
16 CoreFoundation                 0x197465f40 CFRunLoopRunSpecific + 480
17 GraphicsServices               0x1a16f6534 GSEventRunModal + 108
18 UIKitCore                      0x19b5f1580 UIApplicationMain + 1940
19 goForDream                     0x1021a03a8 main + 26 (AuthManager.swift:26)
20 libdyld.dylib                  0x1972e4e18 start + 4

此崩溃表明在cellForItemAt委托方法中生成单元格时存在问题,因此首先尝试重新生成此问题,该问题提供了有关crashI的更多详细信息,但无法在设备或模拟器上复制此问题。请共享您的集合视图委托code@SilverskyTechnology如果您在这里显示控制台日志中打印的崩溃原因,那就太好了!不会生成崩溃,但我认为这一行中的单元格中存在问题“collectionView.dequeueReusableCell(for:indexPath)as FeedPostCarouselCollectionViewCell”正确的方法是“let cell=collectionView.dequeueReusableCell(with ReuseIdentifier:“FeedPostCarouselCollectionViewCell”,for:indexPath)as!FeedPostCarouselCollectionViewCell”
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
    return assets.count == 1 ? 0 : assets.count
}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    let cell = collectionView.dequeueReusableCell(for: indexPath) as FeedPostCarouselCollectionViewCell
    if !assets.isEmpty {
        let photo = assets[indexPath.row]
        cell.configure(with: photo)
    }
    return cell
}