我正在使用revmob在我的应用中展示广告。我曾经拥有它,以便每次按下我的计时器的停止按钮时,都会显示一则广告。我想让它显示更少。例如,用户按下按钮一次,没有任何反应。第二次,广告出现了。因此,广告出现了2次中的1次。 2次中有2次,广告出现等等。
我正在使用代码发布广告:
- (IBAction)Stop {
[timer invalidate];
if (self.fullscreen) [self.fullscreen showAd];
}
我只是想要一种方法来计算按下停止按钮的次数,每隔2次,显示一个广告=) 提前谢谢。
答案 0 :(得分:1)
您只需跟踪其显示的次数。我试图保持代码可以理解,所以这有点矫枉过正。
@property (nonatomic, assign) int currentViews;
@property (nonatomic, assign) int maxViewCount;
然后在viewDidLoad
(或等效的)
self.currentViews = 0;
self.maxViewCount = 2; // show it every 2nd view
然后递增并检查:
- (IBAction) Stop {
[timer invalidate];
self.currentViews++;
if ((self.fullscreen) && (self.currentlViews == self.maxViewCount)) {
self.currentViews = 0; // reset the view count
[self.fullscreen showAd];
}