小编Dee*_*pta的帖子

如何在iOS 7中超过180秒的后台运行NSTimer?

我试过这个但是在iOS 7和Xcode 4.6.2中的工作时间不超过180秒.请帮我

    UIBackgroundTaskIdentifier bgTask = UIBackgroundTaskInvalid;
        UIApplication *app = [UIApplication sharedApplication];
       bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
            [app endBackgroundTask:bgTask];
        }];
        NSTimer  *timer = [NSTimer scheduledTimerWithTimeInterval:20 target:self   selector:@selector(timerMethod) userInfo:nil repeats:YES];
        [[NSRunLoop currentRunLoop] addTimer:timer forMode:NSRunLoopCommonModes];
     -(void) timerMethod{

     NSLog(@"in timerMethod");
    }
Run Code Online (Sandbox Code Playgroud)

timer nstimer ios

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

ios ×1

nstimer ×1

timer ×1