이 추가가있는 viewDidLoad입니다 :
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnteredBackground) name:UIApplicationDidEnterBackgroundNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationEnteredForeground) name:UIApplicationDidEnterForegroundNotification object:nil];
쓰기 알림 기능을 처리하십시오.
-(void)applicationEnteredBackground
{
//storing timestamp when user goes background
NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
[userDefaults setObject:[NSDate date] forKey:@"timeStamp"];
[userDefaults synchronize];
}
-(void)applicationEnteredForeground
{
NSUserDefaults *userDefaults=[NSUserDefaults standardUserDefaults];
NSString *lastTimeOpened= [userDefaults objectForKey:@"timeStamp"];
NSDateFormatter *formatter=[[NSDateFormatter alloc]init];
//set formatter style as long
if([[NSDate date] timeIntervalSinceDate:[formatter dateFromString:lastTimeOpened]] > X hours)
{
//reload your webview here.
}
}
안녕하세요, 작은 논리 오류가있을 수 있지만이 방법은 저에게 맡겨주세요. – satheeshwaran
@sharataka 작동 했습니까? 네가 그걸로 멋지다면 내 ans 투표를 수락하십시오. – satheeshwaran