gpt4 book ai didi

ios - Chartboost 代表无法快速工作

转载 作者:行者123 更新时间:2023-11-30 11:37:50 24 4
gpt4 key购买 nike

期望:当委托(delegate)方法调用时我想做点什么观察到:委托(delegate)方法没有成功调用广告在屏幕上的显示错误代码:Chartboost.delegate=self

错误:类型“Chartboost”没有成员“代表”

AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool  {

Chartboost.start(withAppId: "4f21c409cd1cb2fb7000001b", appSignature: "92e2de2fd7070327bdeb54c15a5295309c6fcd2d", delegate: nil)

return true
}

ViewController代码

class ViewController: UIViewController,GADBannerViewDelegate, GADInterstitialDelegate,GADRewardBasedVideoAdDelegate,IMBannerDelegate, IMInterstitialDelegate ,ChartboostDelegate{

@IBAction func Vedio(_ sender: Any) {

Chartboost.showRewardedVideo(CBLocationMainMenu)

}

@IBAction func LoadFullAd(_ sender: Any) {

Chartboost.showInterstitial(CBLocationHomeScreen)
}

private func shouldDisplayRewardedVideo(_ location: CBLocation) -> Bool {
return true
}

private func shouldRequestInterstitial(_ location: CBLocation) -> Bool {
return true
}

}

最佳答案

A 必须使用 Chartboost.setDelegate(self) 将委托(delegate)设置为 self

 func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

Chartboost.start(withAppId: "4f21c409cd1cb2fb7000001b", appSignature: "92e2de2fd7070327bdeb54c15a5295309c6fcd2d", delegate:self as ChartboostDelegate)
Chartboost.setDelegate(self as ChartboostDelegate)

return true
}

在了解了如何在 Swift 中正确转换 Objective-C 方法之后,我添加了下划线 (_),将函数更改为:

func shouldDisplayRewardedVideo(_ location: CBLocation) -> Bool
{

return true
}
func shouldRequestInterstitial(_ location: CBLocation) -> Bool {

return true
}

XCode 然后给了我一个提示,我已经接近委托(delegate)方法,但需要更改位置类型,最终得到

func shouldDisplayRewardedVideo(_ location: String) -> Bool
{

return true
}
func shouldRequestInterstitial(_ location: String) -> Bool {

return true
}

关于ios - Chartboost 代表无法快速工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49547734/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com