2

私は最初のアプリに数か月取り組んでおり、アプリ ストアに送信する前に広告を追加する必要がある段階にあります。iAD を正常に追加し、Chartboost を構成しようとしています。

ゲームの特定の部分で Chartboost がインタースティシャルを表示しないようにしようとすると、問題が発生します。Chartboost の Web サイトと Chartboost.h ファイルのドキュメントに従って、次のように場所を設定しました。

// Return NO if showing an interstitial is currently inappropriate, for example if the user has entered the main game mode
- (BOOL)shouldDisplayInterstitial:(NSString *)location;

これがばかげた質問のように聞こえる場合は申し訳ありませんが、私はiOSの本とオンラインで答えを探していましたが、それは簡単だと確信しています. 別のクラスから (BOOL)shouldDisplayInterstitial に YES を返すにはどうすればよいですか。私の GameViewController.m からの IE ?

4

3 に答える 3

0

1)Chartboostオブジェクトを作成し、それにデリゲートを設定しました。

Chartboost *cb = [Chartboost sharedChartboost];
cb.delegate = self;  

shouldDisplayInterstitial2)メソッドを実装する必要があるデリゲートの場合は Self

- (BOOL)shouldDisplayInterstitial:(NSString *)location
{
    return YES;
}

サンプルプロジェクトはこちら

于 2014-04-09T11:28:27.760 に答える
0

他のクラスから YES/No を返すにはどうすればよいですか?

1.委任は問題です。Chartboost のデリゲートを GameViewController クラスに設定します

Chartboost *cb = [Chartboost sharedChartboost];
cb.delegate = self;//Specify your GameViewController object instead of self;

2.クラスにメソッドを実装する

 - (BOOL)shouldDisplayInterstitial:(NSString *)location
 {
    return YES;
 }

ベスト プラクティス:ソース

初走行体験

ユーザーがゲームを初めてプレイした後にのみインタースティシャルを表示することは、良い習慣です (iOS ヒューマン インターフェース ガイドラインにも記載されています)。

以下の Chartboost SDK デリゲート メソッドを使用して、2 回目の startSession までインタースティシャルを防止できます。

- (BOOL)shouldRequestInterstitialsInFirstSession {
    return NO;
}

この例を参照してください

https://github.com/ChartBoost/client-examples/blob/master/iOS/ChartboostExample/ExampleAppAppDelegate.m

iPhone プロジェクトでの Chartboost / iOS での Chartboost の使用

于 2014-04-09T11:41:47.287 に答える
0

委任を通じて。宣言する必要があるクラスがshouldDisplayInterstitial:質問に答えられない場合は、次のことができるクラスに質問する必要があります。

- (BOOL) shouldDisplayInterstitial: (NSString *)location
{
    return [self.delegate shouldDisplayInterstitial:location];
}

デリゲートは、特定のプロトコルに準拠し、メソッドを実装する必要があります。

委任の詳細については、こちらを参照してください。

于 2014-04-09T11:36:41.103 に答える