2013-06-08 3 views
1

게임 시작시 다음 환영 알림을 제거하려고했습니다.Nextpeer 환영 배너 제거 : 위임 방법이 실행되지 않음

여기에 큰 작업 AppDelegate.m

- (void)initializeNextpeer 
{ 
    NSDictionary* settings = [NSDictionary dictionaryWithObjectsAndKeys: 

           // This game has no retina support - therefore we have to let the platform know 
           [NSNumber numberWithBool:TRUE], NextpeerSettingGameSupportsRetina, 
           // Support orientation change for the dashboard notifications 
           [NSNumber numberWithBool:FALSE], NextpeerSettingSupportsDashboardRotation, 
           // Support orientation change for the in game notifications 
           [NSNumber numberWithBool:TRUE], NextpeerSettingObserveNotificationOrientationChange, 
           // Place the in game notifications on the bottom screen (so the current score will be visible) 
           [NSNumber numberWithInt:NPNotificationPosition_BOTTOM], NextpeerSettingNotificationPosition, 
           nil]; 



    [Nextpeer initializeWithProductKey:@"HERE ADDED GAME KEY" andSettings:settings andDelegates: 
    [NPDelegatesContainer containerWithNextpeerDelegate:self notificationDelegate:[NPCocosNotifications sharedManager] tournamentDelegate:self]]; 


} 
- (BOOL)nextpeerShouldShowWelcomeBanner { 
    return NO; // Do not Show banner 
} 

Nextpeer에서

@interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..> 

// .H

내 코드입니다. 이 기능 만 실행되지 않습니다. 뭐가 문제 야?

+1

에 추가됩니다 당신을했다 nextpeer의 위임자로 appdelegate를 지정/등록 하시겠습니까? – LearnCocos2D

+0

@ LearnCocos2D 예 nextpeerDashboardWillAppear 대리자 호출이 시작되었지만 nextpeerShouldShowWelcomeBanner가 아닌 것을 추가했습니다. – Guru

답변

1

nextpeerShouldShowWelcomeBannerNextpeerDelegate이 아니라 NPNotificationDelegate의 메소드입니다. 코드 샘플에서 알림 위임은 [NPCocosNotifications sharedManager]입니다. 따라서 메서드를 해당 객체로 이동하거나 다른 알림 위임자를 설정해야합니다.

+0

고마워요. 지금은 대단한 일. – Guru

1

편집 : 이것은 더 이상 적용되지 않습니다. 현재 버전의 Nextpeer (1.7.4)는이 기능을 지원하지 않습니다.

NextPeerDelegate이 아닌 NPNotificationDelegate을 구현하는 클래스에이 메서드를 추가해야합니다.

하지만 문제는 기본값 인 NPNotificationDelegateNPCocosNotifications이며 이는 Nextpeer 라이브러리의 클래스입니다. 따라서 라이브러리를 업데이트 할 때 새 버전 NPCocosNotifications으로 다시 편집해야한다는 것을 기억해야합니다.

그러나 범주를 사용하여이를 수행하는 더 좋은 방법은 업데이트 할 때 다시 편집 할 필요가 없다는 것을 의미합니다. 확인하는 프로젝트에 해당 파일은 "대상 그룹의 폴더에 복사합니다 (NSObject+NPCocosNotification_NotShowWelcomeBanner.m

#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h" 

@implementation NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner) 

- (BOOL)nextpeerShouldShowWelcomeBanner { 
    return NO; // Do NOT show banner as the game starts up 
} 

@end 

드래그 : NSObject+NPCocosNotification_NotShowWelcomeBanner.h

#import <Foundation/Foundation.h> 
#import "NPCocosNotifications.h" 

@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner) 

@end 

이 파일을 만듭니다

1)

이 파일을 만듭니다 필요한 경우) "가 선택되고"대상에 추가하십시오 (프로젝트의 빌드 대상 이름) ".

2) 앱 대리인에게이 라인을 추가하고 NPCocosNotification

// This adds a method to prevent the welcome banner showing 
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h" 

새로운 방법을 참조하는 다른 파일이 배너를 해제, NPCocosNotifications :

+0

답장을 보내 주셔서 감사합니다 ... 블라디미르의 솔루션은 이전에 작동 했었습니다 ... 지금 테스트하지 않았습니다 ... 귀하의 답변을 보았을 때 다시 부러진 것 같아요 ...이 솔루션 덕분입니다. – Guru

+0

나는 그것이 (그리고 다른 사람들에게) 도움이 되었기를 희망한다! 이것은 사실 블라디미르 Gritsenko가 부여했지만 Nextpeer 라이브러리 코드 대신 애플리케이션 코드에 구현 된 것과 동일한 솔루션입니다. 확실하게; 블라디미르 Gritsenko의 대답은 잘 작동하지만 당신이 Nextpeer를 업데이트 할 때마다 그것을 다시하는 것을 기억해야합니다 :) – RedYeti