背景线程上的IOS警告

问题描述:

我在后台线程下载图像,并在主线程上将此图像设置为UIImageView。但它给我一些警告象背景线程上的IOS警告

Using low GPU priority for background rendering 

同时请参阅下面的代码以供参考

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^(void) { 
    int randomImgNum = [[contentDict valueForKey:@"imageIndex"]intValue]; 
    UIImage *image = [UIImage imageNamed:[Utils getImageFromIndex:randomImgNum]]; 
    UIImage *newBlurredImage = [image blurredImageWithRadius:5.0]; 
    dispatch_sync(dispatch_get_main_queue(), ^(void) { 
     customVieww.imgCardView.image = image; 
     [self setBlurrImage:newBlurredImage]; 
    }); 
}); 

请让我知道可能是什么问题,我们怎样才能解决这个问题。

如果我错过了任何事,请让我知道任何解释。

预先感谢您。

+0

为什么DISPATCH_QUEUE_PRIORITY_BACKGROUND不DISPATCH_QUEUE_PRIORITY_DEFAULT –

+0

谢谢麦克我已经尝试了这个解决方案很好,但仍然得到同样的警告 –

+1

我假设问题是由'blurredImageWithRadius'引起的。你可以发布特定方法的代码吗? –

,如果你想你必须使用主队列 主视图中工作,因为如果你使用一个后台队列改变的UIView

更新代码,它可能会导致一个问题:

dispatch_async(dispatch_get_main_queue(), ^{ 
    int randomImgNum = [[contentDict valueForKey:@"imageIndex"]intValue]; 
    UIImage *image = [UIImage imageNamed:[Utils getImageFromIndex:randomImgNum]]; 
    UIImage *newBlurredImage = [image blurredImageWithRadius:5.0]; 
    dispatch_sync(dispatch_get_main_queue(), ^(void) { 
     customVieww.imgCardView.image = image; 
     [self setBlurrImage:newBlurredImage]; 
    }); 
}); 
+0

您能解释一下在给定问题中影响UI的背景队列中运行的进程是什么? –

+0

谢谢兄弟,但我们没有更新后台线程上的任何UI如果我们没有使用任何后台线程,将使用main_queue –

+0

谢谢@KKRocks但是我会在哪里解决问题。 –

+0

为每个矩形创建一个CALayer并将它们添加为UIImage的子图层。 CALayer层次结构由GPU渲染。 – KKRocks