我正在尝试将 Tapjoy 用于我的应用程序,并且我正在使用以下代码
-(void)getTapJoyAd{
[Tapjoy getFullScreenAd];
// A notification method must be set to retrieve the fullscreen ad object.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getFullScreenAd:)
name:TJC_FULL_SCREEN_AD_RESPONSE_NOTIFICATION
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(fullscreenAdClosed:)
name:TJC_VIEW_CLOSED_NOTIFICATION
object:nil];
// This method requests the tapjoy server for current virtual currency of the user.
[Tapjoy getTapPoints];
// A notification method must be set to retrieve the points.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getUpdatedPoints:) name:TJC_TAP_POINTS_RESPONSE_NOTIFICATION object:nil];
}
问题是当我再次记忆起这个方法时,它同时打开了两个屏幕.. 我越多调用此方法,打开的屏幕就越多..
最佳答案
基本上,问题是您的notification
被观察到多少次,然后您的方法正在执行。因此,您可以防止此问题的一种方法是,一旦发布并观察到 notification
,然后删除您的 notification observer
。这也取决于您的代码,即您如何处理 notification
部分。所以尝试删除观察者
并检查以下内容:-
-(void)viewDidDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter]removeObserver:self name:TJC_FULL_SCREEN_AD_RESPONSE_NOTIFICATION object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self name:TJC_VIEW_CLOSED_NOTIFICATION object:nil];
[[NSNotificationCenter defaultCenter]removeObserver:self name:TJC_TAP_POINTS_RESPONSE_NOTIFICATION object:nil];
}
关于iOS:Tapjoy 全屏广告打开多个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20582228/