- (void)applicationWillResignActive:(UIApplication *)application {
background_task =[[UIApplication sharedApplication] beginBackgroundTaskWithName:@"i360Doc" expirationHandler:^
{
NSLog(@"EndDate = %@",[NSDate date]);
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
}];
if(!timer)
{
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startTimer) userInfo:nil repeats:YES];
}
NSLog(@"startDate = %@",[NSDate date]);
}
-(void)startTimer
{
double TimeRemaining = [[UIApplication sharedApplication] backgroundTimeRemaining];
NSLog(@"Background time Remaining: %f",TimeRemaining);
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
}
background_task =[[UIApplication sharedApplication] beginBackgroundTaskWithName:@"i360Doc" expirationHandler:^
{
NSLog(@"EndDate = %@",[NSDate date]);
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
}];
if(!timer)
{
timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(startTimer) userInfo:nil repeats:YES];
}
NSLog(@"startDate = %@",[NSDate date]);
}
-(void)startTimer
{
double TimeRemaining = [[UIApplication sharedApplication] backgroundTimeRemaining];
NSLog(@"Background time Remaining: %f",TimeRemaining);
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
[application endBackgroundTask: background_task];
background_task = UIBackgroundTaskInvalid;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货