Browse Source

【ios】在恢复出厂中,退出后台运行,倒计时不会发生变化

huangxiaodong 1 year ago
parent
commit
09387b6aab
1 changed files with 4 additions and 0 deletions
  1. 4 0
      创维盒子/双子星云手机/Class/ComontAlretViewController.m

+ 4 - 0
创维盒子/双子星云手机/Class/ComontAlretViewController.m

@@ -262,8 +262,12 @@
         curTitle = [[NSString alloc] initWithFormat:@"%@(%ld)",curTitle,countdownSeconds];
         [but setTitle:curTitle forState:UIControlStateNormal];
         
+        [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
+             [[UIApplication sharedApplication] endBackgroundTask:UIBackgroundTaskInvalid];
+        }];
         [curTimer invalidate];
         curTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(handleCountdownFun) userInfo:nil repeats:YES];
+        [[NSRunLoop mainRunLoop] addTimer:curTimer forMode:NSRunLoopCommonModes];
     }
 }