0
當應用程序在後臺運行時,我的應用程序未更新Web服務的信息。在後臺運行時,應用程序不會自行更新
-(void)onTick:(NSTimer *)timer {
[self parseData];
[self.tableView reloadData];
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSDate *d = [NSDate dateWithTimeIntervalSinceNow: 60.0];
NSTimer *t = [[NSTimer alloc] initWithFireDate: d
interval: 30.0
target: self
selector:@selector(onTick:)
userInfo:nil repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:t forMode: NSDefaultRunLoopMode];
}
如果應用程序是可見的比一切都順利,只要它被投入直到我再次把應用推到前臺它不更新數據的背景。
有什麼想法或建議是什麼導致了這個?
非常感謝。
的可能重複[iOS的:保持應用程序後臺運行(http://stackoverflow.com/questions/10674004/ios-keep-application-running-in-background) – tommyo