2015-12-30 13 views
0

我已经在AppStore中开发并部署了我的应用程序。它正在成功运行。如何通过检测Xcode7中单独屏幕中的时间花费来显示我们的对话框

现在,我在实现Rate us对话框时遇到了一个逻辑问题。

我想显示自定义对话框时用户花费在我的应用程序5 mins30 Seconds在任何屏幕。

Curently其中谈到在我心中唯一的解决办法是使用:

performSelector:withObject:afterDelay: 

但我不知道这是好还是不好。他们是否有其他方式来实现这一目标?

编辑

我已经实现这段代码中的applicationDidFinishLaunching:

self.timerForScreenTimeOut = [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(idleTimerExceeded) userInfo:nil repeats:YES]; 

现在,我怎么能检测多少秒,尤其是屏幕popingNavigation Controller之前结束。

+0

[看看这个](https://www.cocoacontrols.com/controls/irate)&[others](https://www.cocoacontrols.com/search?q=rate) –

+0

5分钟&费率30秒?不要急于评价你的应用程序,否则你将有错误的评级... –

+0

@FahimParkar我会在一天内只做一次或两次...我无法跟踪屏幕切换...感谢您的链接...但我不想使用任何库..我已经实现了一些东西..只有一个问题,我面临着:( – Dalvik

回答

0
you can call your method inside applicationWillEnterForeground:. 
For example: dispatch_async(dispatch_get_main_queue(), ^{ 
       NSTimer *rateTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0 
                    target: self 
                   selector: @selector(showRatePrompt) 
                   userInfo: nil repeats:YES]; 
      }); 
+0

是的我已经完成了这个...但是现在我怎么才能检测到屏幕已经过时 – Dalvik

+0

@RahulMishra带一个名为秒的全局int变量。在你的计时器的方法中,增加你的秒数,因此你可以得到在屏幕上的时间流逝 – Wolverine

+0

我把它作为答案 – Wolverine

0

为了检测屏幕

经过的时间在viewdidlod

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    //create Global variable of NSInteger *seconds and initialise it with 0 
    seconds = 0; 

    NSTimer *Secondtimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(increaseTimeCount) userInfo:nil repeats:YES]; 
    [Secondtimer fire]; 
} 

而在你increaseTimeCount方法,加大秒。

- (void)increaseTimeCount { 
    seconds++; 
} 

所以当价值将达到30个,那么你可以展示你的警觉和无效的计时器。

+0

我有更多的30个屏幕..我必须管理所有这些屏幕 – Dalvik

+0

然后把这段代码放在一个普通的类或Appdelegate类中,每次当你进入一个新的屏幕时,你将启动一个计时器,当用户弹出或解散时,它会增加你的秒数和计时器。当用户在任何屏幕上停留超过30秒。你将能够显示你的警报评价应用程序 – Wolverine

相关问题