2014-04-09 6 views
2

나는 첫 번째 앱을 몇 달 동안 사용해 왔으며 앱 스토어로 보내기 전에 광고를 추가해야하는 단계에 있습니다. 성공적으로 iAD를 추가했으며 Chartboost를 구성하려고합니다.AppDelegate 클래스의 BOOL에 YES를 반환하는 방법은 무엇입니까?

Chartboost에서 내 게임의 특정 부분에 삽입 광고를 표시하지 못하게하려고 할 때 문제가 발생합니다. 나는 Chartboost 웹 사이트와 Chartboost.h이 파일에 문서에 따라 위치를 설정 한 상태 :

이 바보 같은 질문처럼 들리지만 내 아이폰 OS 책을 통해 온라인으로 검색하고 한 경우
// Return NO if showing an interstitial is currently inappropriate, for example if the user has entered the main game mode 
- (BOOL)shouldDisplayInterstitial:(NSString *)location; 

죄송합니다 왜냐하면 확실한 대답은 간단합니다. 다른 클래스의 (BOOL) shouldDisplayInterstitial에 YES를 어떻게 반환합니까? 내 GameViewController.m의 I.E?

+0

Infact는이 방법에 예상되는이 예제를 참조하십시오

당신은 두 번째 startSession 때까지 삽입을 방지하기 위해 Chartboost SDK의 대리자 메서드 아래를 사용할 수 있습니다 YES 또는 NO를 반환하고, 문자열을 매개 변수로 기대합니다. –

답변

0

어떻게 다른 클래스의 YES/No를 반환합니까?

1.Delegate는 중요합니다. 클래스에 GameViewController 클래스에

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

2.implement 방법을 Chartboost의 대리자를 설정

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

모범 사례 : Source

첫 실행 경험

좋은거야. 연습 (iOS 휴먼 인터페이스 가이드 라인에 명시)을 통해 사용자가 처음으로 게임을 한 후에 만 ​​전면 광고를 표시 할 수 있습니다.

- (BOOL)shouldRequestInterstitialsInFirstSession { 
    return NO; 
} 

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

Chartboost in iphone project/Chartboost usage in iOS

+0

게임의 특정 부분 (다른 클래스에서)에서 앱 대리자의 (BOOL) shouldDisplayInterstitial로 NO를 반환하는 방법에 대한 예가없는 것 같습니다. github에 대해 알고 있습니까? –

+0

질문이 없습니다. –

+0

안녕하세요. @ Vijay-Apple-Dev.blogspot.com 어떻게해야하는지 알았습니다. 다음은 샘플 코드입니다 : [링크] (https://gist.github.com/DanielTomlinson/8a59a9cd64a911a0f3a4) 당신은 AppDelegate에의 VOID 방법을 생성하고 BOOL 방법에 반환 값을 전달하는 것을 사용한다. 대접 했어요! –

0

1) Chartboost 개체를 만들고 여기에 대리인을 설정했습니다.

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

2) 자기 shouldDisplayInterstitial 방법을 구현해야 대리인이

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

대표를 통해 example project here

+0

그래서 내가 shouldDisplayInterstitial하는 NO를 반환 할 내 GameViewController에 : 나는 CB 위양이 다음 AppDelegate에있는 BOOL에 NO 또는 FALSE를 보내 호출해야합니다. 이걸 어떻게 만들까요? 나는 이와 같은 것을 가정하고있다 : [cb shouldDisplayInterstitial (NO)]; ? –

0

를 참조합니다. 당신이 shouldDisplayInterstitial:를 선언하는 데 필요한 클래스가 질문에 대답 할 수없는 경우, 그것은 할 수있는 클래스를 요청해야합니다 :

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

귀하의 대리인이 특정 프로토콜을 준수하고 방법을 구현해야합니다.

위임에 대한 자세한 내용은 here입니다.

관련 문제