如果第一个单元格,FBNativeAdsManager nextNativeAd() 会崩溃

Posted

技术标签:

【中文标题】如果第一个单元格,FBNativeAdsManager nextNativeAd() 会崩溃【英文标题】:FBNativeAdsManager nextNativeAd() is crashing if first cell 【发布时间】:2016-01-06 08:16:29 【问题描述】:

如果单元格是第一个,则代码会在以下行中崩溃

let nativeAdd = nativeAdsManager.nextNativeAd() as FBNativeAd?

我猜广告还没有准备好什么的。但是不应该崩溃!!!我尝试将其放入 do-try-catch 中,但没有帮助。

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell
    
        if (self.shouldShowAd(indexPath))
        
            let cell = collectionView.dequeueReusableCellWithReuseIdentifier(NSStringFromClass(AdCell), forIndexPath: indexPath) as! AdCell

            let nativeAdd = nativeAdsManager.nextNativeAd() as FBNativeAd?

            if (nativeAdd != nil)
            
                cell.setDetails(nativeAdd!)
                return cell
            
            else
            
                return self.createRegularCell(collectionView, cellForItemAtIndexPath: indexPath)
            
        
        else
        
            return self.createRegularCell(collectionView, cellForItemAtIndexPath: indexPath)
        
    

【问题讨论】:

您能发布您收到的任何错误消息/代码吗? 日志表明崩溃发生在什么地方? 你修好了吗? @Luda 【参考方案1】:

我有类似的问题,点击广告时很少崩溃(在my app 的第 5 个单元格中,使用 FBAudienceNetwork ios SDK 4.26.0 和 CocoaPods)

致命异常:NSInvalidArgumentException -[FullScreenCatalogViewController nativeAdDidClick:]:无法识别的选择器发送到实例 0x161ff12d0

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x185dabd38 __exceptionPreprocess
1  libobjc.A.dylib                0x1852c0528 objc_exception_throw
2  CoreFoundation                 0x185db91f8 __methodDescriptionForSelector
3  UIKit                          0x18f573cc4 -[UIResponder doesNotRecognizeSelector:]
4  CoreFoundation                 0x185db13f0 ___forwarding___
5  CoreFoundation                 0x185c970dc _CF_forwarding_prep_0
6  Black Friday                   0x100f446e0 __33-[FBMediaView loadMultiProductAd]_block_invoke_2 (FBMediaView.m:447)
7  Black Friday                   0x100f5f9f0 -[FBAdCommandProcessor callCompletionHandlerForCommand:withAdAction:] (FBAdCommandProcessor.m:296)
8  Black Friday                   0x100f5f938 -[FBAdCommandProcessor launchURLOutOfApp:withAdAction:] (FBAdCommandProcessor.m:283)
9  Black Friday                   0x100f5ec84 -[FBAdCommandProcessor launchAppForEngagement:] (FBAdCommandProcessor.m:164)
10 Black Friday                   0x100f5ea2c -[FBAdCommandProcessor processCommand:withExtraData:adDataModel:completionHandler:] (FBAdCommandProcessor.m:142)
11 Black Friday                   0x100f444d0 __33-[FBMediaView loadMultiProductAd]_block_invoke.218 (FBMediaView.m:439)
12 Black Friday                   0x100f84540 -[FBAdMultiProductView multiProductCellClicked:withPosition:inRect:] (FBAdMultiProductView.m:115)
13 Black Friday                   0x100f83b28 -[FBAdMultiProductCell dispatchClickedWithPosition:inRect:] (FBAdMultiProductCell.m:151)
14 Black Friday                   0x100f839f0 -[FBAdMultiProductCell gestureRecognizerTappedCell:] (FBAdMultiProductCell.m:129)
15 UIKit                          0x18f848f78 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:]
16 UIKit                          0x18f84d4dc _UIGestureRecognizerSendTargetActions
17 UIKit                          0x18f337dc8 _UIGestureRecognizerSendActions
18 UIKit                          0x18f1ec748 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
19 UIKit                          0x18f8373fc _UIGestureEnvironmentUpdate
20 UIKit                          0x18f836f88 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:]
21 UIKit                          0x18f8360e4 -[UIGestureEnvironment _updateGesturesForEvent:window:]
22 UIKit                          0x18f1eaa54 -[UIWindow sendEvent:]
23 UIKit                          0x18f1bc078 -[UIApplication sendEvent:]
24 UIKit                          0x18fafbf98 __dispatchPreprocessedEventFromEventQueue
25 UIKit                          0x18fafe408 __handleEventQueueInternal
26 UIKit                          0x18faf7574 __handleHIDEventFetcherDrain
27 CoreFoundation                 0x185d54358 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
28 CoreFoundation                 0x185d542d8 __CFRunLoopDoSource0
29 CoreFoundation                 0x185d53b60 __CFRunLoopDoSources0
30 CoreFoundation                 0x185d51738 __CFRunLoopRun
31 CoreFoundation                 0x185c722d8 CFRunLoopRunSpecific
32 GraphicsServices               0x187b03f84 GSEventRunModal
33 UIKit                          0x18f21f880 UIApplicationMain
34 Black Friday                   0x100e7649c main (main.m:15)
35 libdyld.dylib                  0x18579656c start

【讨论】:

我正在使用 FBAudienceNetwork iOS SDK 4.26.0 并在收到大量崩溃报告后更新到 4.26.1,等待看看情况如何。

以上是关于如果第一个单元格,FBNativeAdsManager nextNativeAd() 会崩溃的主要内容,如果未能解决你的问题,请参考以下文章

从 UITest 中选择集合视图中的第一个单元格

复制并粘贴到另一个工作表的第一个空行,如果第一个单元格为空,则粘贴到上一行

在excel里面单元格合并后筛选时为啥只能显示第一行,剩下的为啥显示不出来,怎么操作?

如果单元格中的计算值发生变化,则更改单元格颜色

多个自定义 UITableViewCell 相互覆盖 Swift

滑块更改会影响其他表格单元格