我试着在游戏开始时删除下一个伙伴的欢迎通知。
下面是我用.h编写的代码
@interface AppDelegate : NSObject <UIApplicationDelegate,NextpeerDelegate,NPTournamentDelegate,NPNotificationDelegate,..>//在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工作得很好。只有这个函数不会被触发。怎么了?
发布于 2013-06-10 15:55:13
nextpeerShouldShowWelcomeBanner是NPNotificationDelegate上的方法,而不是NextpeerDelegate上的方法。在您的代码示例中,通知委托为[NPCocosNotifications sharedManager]。因此,您应该将该方法移动到该对象,或者设置不同的通知委托。
发布于 2013-10-08 02:02:46
EDIT: 这不再适用-似乎当前版本的Nextpeer (1.7.4)不支持这一点。
您需要将该方法添加到实现NPNotificationDelegate而不是NextPeerDelegate的任何类中。
但问题是,默认的NPNotificationDelegate是NPCocosNotifications -这是Nextpeer库中的一个类。因此,在更新库时,还需要记住对新版本的NPCocosNotifications再次进行相同的编辑。
但有一种更简洁的方法可以使用类别来实现这一点,这意味着你在更新时不需要再次进行编辑。
1)
创建此文件:NSObject+NPCocosNotification_NotShowWelcomeBanner.h
#import <Foundation/Foundation.h>
#import "NPCocosNotifications.h"
@interface NPCocosNotifications (NPCocosNotification_NotShowWelcomeBanner)
@end创建此文件: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将这些文件拖到项目中,确保选择了"Copy into target group's folder (if needed)“和"Add to target (your project's build target name)”。
2)将此行添加到您的应用委托和引用NPCocosNotification的任何其他文件中
// This adds a method to prevent the welcome banner showing
#import "NSObject+NPCocosNotification_NotShowWelcomeBanner.h"关闭横幅的新方法将添加到NPCocosNotifications :)
https://stackoverflow.com/questions/16996714
复制相似问题