performFetchWithCompletionHandler 只被调用
Posted
技术标签:
【中文标题】performFetchWithCompletionHandler 只被调用【英文标题】:performFetchWithCompletionHandler only get called ones 【发布时间】:2013-09-02 19:03:15 【问题描述】:这是我的应用委托
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:2];
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UINavigationController *nav=[[[UINavigationController alloc]initWithRootViewController:self.viewController ] autorelease];
nav.navigationBar.hidden=YES;
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
-(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
NSLog(@"########### Received Background Fetch ###########");
//Download the Content .
[self sometask]; // i want to do some task here but this method get called only ones when i try to launch application
//Cleanup
completionHandler(UIBackgroundFetchResultNoData);
所以问题是 是的,我已经在信息 pList 中完成了所有操作,但没有帮助,请提出一些建议
【问题讨论】:
问题将出现在您的函数“sometask”中,尝试通过注释行“[self sometask];”来运行它,我认为您使用“调试-> 模拟后台提取”选项正确模拟后台提取。 ,确保调用了CompletionHandler 我有同样的问题,只调用一次。 【参考方案1】:请注意,仅当系统告诉您执行后台提取时才应调用此方法。
您可以在 Xcode 中进行模拟:
【讨论】:
以上是关于performFetchWithCompletionHandler 只被调用的主要内容,如果未能解决你的问题,请参考以下文章