大佬教程收集整理的这篇文章主要介绍了xcode – 延迟更新标签栏项目的徽章价值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
NSString *chkUrl = @"http://domain.com/script.PHP"; NSURL *url = [[[NSURL alloc] initWithString:chkUrl] autorelease]; NSError *error = nil; NSStringEncoding encoding; NSString *returnHTML = [[NSString alloc] initWithContentsOfURL:url usedEncoding:&encoding error:&error]; int @R_345_10586@lNewmessages = [[returnHTML StringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue]; AppDelegate *mainDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"badge before:%@",[[mainDelegate.tabBarController.viewControllers objectATindex:2] tabBarItem].badgevalue); [[mainDelegate.tabBarController.viewControllers objectATindex:2] tabBarItem].badgeValue = [NSString StringWithFormat:@"%d",@R_345_10586@lNewmessages]; NSLog(@"badge after:%@",[[mainDelegate.tabBarController.viewControllers objectATindex:2] tabBarItem].badgevalue);
问题是徽章值没有立即更新!也许在第四次通话中它会更新!我做错了什么!或者它是iOS中的错误!
作为一种解决方法,我在每次更新时重复上述行10次,但是它再次没有更新,所以问题是更新徽章值的延迟,这不是重新运行更新行的问题!
顺便说一句,这个问题发生在Xcode 4.6 Simulator&我的iPhone 5与iOS 6.1
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,(unsigned long)NULL),^(void) { [self checkNewmessages]; });
当我把它改成下面时,它就像一个魅力!
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{ dispatch_async(dispatch_get_main_queue(),^{ [self checkNewmessages]; }); });
以上是大佬教程为你收集整理的xcode – 延迟更新标签栏项目的徽章价值全部内容,希望文章能够帮你解决xcode – 延迟更新标签栏项目的徽章价值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。