如何在按下导航后退按钮和某些点击事件时加载插页式广告?

时间:2014-12-22 10:28:41

标签: ios objective-c uitableview uinavigationcontroller interstitial

我是iOS开发的新手。我在ViewDidLoad时添加插页式广告,但是当用户在我的应用中点击十次时,我想显示插页式广告,这可能吗?如果可能的话请帮助我找到解决方案。我的应用包含HMSegmentedControll,它有十个不同的UITableView。我还希望在按下NavigationBar后退按钮时显示这些广告。有人可以帮我这个吗?

2 个答案:

答案 0 :(得分:2)

可能像Android中的SharedPreference一样

制作一个全局变量NSObject,如

GlobalVariable.h档案

@property (assign) int touchCount;
+ (TouchCount *)getInstance;
@end

GlobalVariable.m文件

@synthesize touchCount;
static TouchCount *instance = nil;

+(TouchCount *)getInstance
{
@synchronized(self)
{
    if(instance==nil)
    {
        instance= [TouchCount new];
    }
    if (instance.touchCount ==10)
    {
        instance.touchCount=0;
        instance= [TouchCount new];
    }
}
return instance;
}

当您想要触摸计数导入GLobalVariable.h时使用此实例,如

TouchCount *obj=[TouchCount getInstance];

答案 1 :(得分:0)

你可以添加一些全球价值,而不是计数“后退”

在GlobalVariables.h文件中的

是这样的:

 extern int PRJ_back_touches_count;

的.m:

 int PRJ_back_touches_count;

比例如在viewWillDisappear方法PRJ_back_touches_count ++

在viewDidAppear上你可以处理PRJ_back_touches_count实际值