Cocos2d iphone Nextpeer删除欢迎横幅:未激发委托方法

Cocos2d iphone Nextpeer删除欢迎横幅:未激发委托方法,cocos2d-iphone,nextpeer,Cocos2d Iphone,Nextpeer,我试图在游戏开始时删除nextpeer欢迎通知 这是我在.h中的代码 @interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..> 下一个很好。只有此函数未被激发。怎么了?nextpeershouldcomebanner是NPNotificationDelegate上的方法,而不是NextpeerDel

我试图在游戏开始时删除nextpeer欢迎通知

这是我在.h中的代码

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

下一个很好。只有此函数未被激发。怎么了?

nextpeershouldcomebanner
NPNotificationDelegate
上的方法,而不是
NextpeerDelegate
上的方法。在代码示例中,通知委托是
[npcocosconotifications sharedManager]
。因此,您应该将该方法移动到该对象,或设置其他通知委托。

编辑:这不再适用-似乎当前版本的Nextpeer(1.7.4)不支持此操作。

您需要将该方法添加到实现
NPNotificationDelegate
而不是
NextPeerDelegate
的任何类中

但问题是,默认的
NPNotificationDelegate
NPCocosNotifications
——它是Nextpeer库中的一个类。因此,在更新库时,还需要记住对新版本的
npcocosonotifications
再次进行相同的编辑

但是,有一种更简洁的方法可以使用类别来完成此操作,这意味着您不需要在更新时再次进行编辑

(一)

创建此文件:
NSObject+npcocoscosnotification\u NotShowWelcomeBanner.h

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

@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

@end
将这些文件拖到项目中,确保选中“复制到目标组的文件夹(如果需要)”和“添加到目标(项目的生成目标名称)”

(二) 将此行添加到您的应用程序代理和引用
NPCocosNotification

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

关闭横幅的新方法将添加到
npcocosconotifications
:)

您是否已将appdelegate分配/注册为nextpeer的代理?@learncos2D是我添加的,NextPeerDashboard将出现代表呼叫被触发,但不是nextpeerShouldShowWelcomeBanner。感谢您的回答…对我来说,Vladimir的解决方案以前工作过…现在未经测试…看到您的答案,我猜它又坏了…感谢此解决方案。我希望它能帮助您(和其他人)!这实际上与Vladimir Gritsenko给出的解决方案相同,但在应用程序代码中实现,而不是在Nextpeer库代码中实现。要清楚;弗拉基米尔·格里森科(Vladimir Gritsenko)的答案很好,但要求您记住在更新Nextpeer时要重做:)
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

@implementation NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

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

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