首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nextpeer删除欢迎横幅:未激发委托方法

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

Stack Overflow用户
提问于 2013-06-08 14:20:51
回答 2查看 315关注 0票数 1

我试着在游戏开始时删除下一个伙伴的欢迎通知。

下面是我用.h编写的代码

代码语言:javascript
复制
@interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..>

//在AppDelegate.m中

代码语言:javascript
复制
- (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工作得很好。只有这个函数不会被触发。怎么了?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-06-10 15:55:13

nextpeerShouldShowWelcomeBannerNPNotificationDelegate上的方法,而不是NextpeerDelegate上的方法。在您的代码示例中,通知委托为[NPCocosNotifications sharedManager]。因此,您应该将该方法移动到该对象,或者设置不同的通知委托。

票数 1
EN

Stack Overflow用户

发布于 2013-10-08 02:02:46

EDIT: 这不再适用-似乎当前版本的Nextpeer (1.7.4)不支持这一点。

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

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

但有一种更简洁的方法可以使用类别来实现这一点,这意味着你在更新时不需要再次进行编辑。

1)

创建此文件:NSObject+NPCocosNotification_NotShowWelcomeBanner.h

代码语言:javascript
复制
#import <Foundation/Foundation.h>
#import "NPCocosNotifications.h"

@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

@end

创建此文件:NSObject+NPCocosNotification_NotShowWelcomeBanner.m

代码语言:javascript
复制
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

@implementation NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)

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

@end

将这些文件拖到项目中,确保选择了"Copy into target group's folder (if needed)“和"Add to target (your project's build target name)”。

2)将此行添加到您的应用委托和引用NPCocosNotification的任何其他文件中

代码语言:javascript
复制
// This adds a method to prevent the welcome banner showing
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16996714

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档