【发布时间】:2014-05-02 23:05:10
【问题描述】:
我已经尝试过,但在 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");
}
【问题讨论】:
-
@Arvind-Systematix 实际上我有 xcode 4.6.2 版本。这个解决方案可以在那个 Xcode 版本上工作吗?
-
@Arvind-Systematix 我需要 IOS 7 和 xcode 4.6.2 版本的这个功能。
-
您是如何将 IOS 7 与 Xcode 4.6 一起使用的,因为它是在 XCode 5 中引入的? en.wikipedia.org/wiki/Xcode。使用 IOS 7 时,您可以在后台打开/关闭刷新应用程序。
-
我同意你的观点,但我的项目是在 Xcode 4.6.2 中开发的,它在 iOS 6 设备上运行良好,但在 iOS7 设备上运行良好