2016-12-21 4 views
-2

현재 사용자가 UIWebView를 종료 할 때 내 앱에서 앱이 돌아 오면 등급 팝업이 표시됩니다. 나는 나의 방법의 진술 if에서 이것을한다.NSTimer/시간 의존 방식 사용 방법

- (void)viewWillDisappear 
{ 
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; 

if (self.appExitedToWebView) { 
    [self.presentationController showAdvertsWithOfferID:self.offerDetailViewController.offer.offerID completionBlock:nil]; 
} 
} 

그러나 사용자가 15 분 이상 UIWebView에 있었던 경우에만 등급을 표시하려고합니다. 방법에이 종속성을 어떻게 추가합니까? 나는 그것이 NSTimer과 관련이 있다고 추측하고 있습니까?

답변

1

UIWebView를 표시 할 때 start 메서드를 호출 한 다음 위에서 설명한 시간이 timerFired이라는 메서드를 완료 한 후 사용자가 언급 한 시간을 완료했을 때 bool을 설정할 수 있습니다.

-(void)start 
{ 
    timer=[NSTimer scheduledTimerWithTimeInterval:yourtime target:self selector:@selector(timerFired) userInfo:nil repeats:YES]; 

} 
-(void)timerFired 

} 
1

당신이 코드

timer=[NSTimer scheduledTimerWithTimeInterval:yourtime target:self selector:@selector(showAlert) userInfo:nil repeats:NO]; 

-(void)showAlert { 
    [timer invalidate]; 
    [self.presentationController showAdvertsWithOfferID:self.offerDetailViewController.offer.offerID completionBlock:nil]; 
} 
+0

사용할 수있는 것이 기존 방법으로이 적합? –

+0

이 코드를 if 조건에 넣으십시오. –