ios - CIFilter减慢滚动
<p><p>我正在将 <code>CIFilter</code> 应用到 <code>UIImage</code>,但它会减慢我的 <code>UITableView</code> 上的滚动速度。有什么我能做的吗?</p>
<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"tweetCell";
TweetCell *cell = (TweetCell *);
if (cell == nil)
{
NSArray *nib = [ loadNibNamed:@"TweetCell" owner:self options:nil];
cell = ;
}
cell.tweet.text = _tweets[@"text"];
NSDictionary *tweetData = _tweets;
NSString *profilePhotoURL = _profilePhotos];
UIImage *bgPicture = ]];
dispatch_async(dispatch_get_main_queue(), ^(void){
CIFilter *gaussianBlurFilter = ;
;
] forKey:kCIInputImageKey];
;
CIImage *outputImage = ;
CIContext *context = ;
CGRect rect = ;
rect.origin.x += (rect.size.width- bgPicture.size.width ) / 2;
rect.origin.y += (rect.size.height - bgPicture.size.height) / 2;
rect.size = bgPicture.size;
CGImageRef cgimg = ;
UIImage *image = ;
CGImageRelease(cgimg);
cell.bgP.image = image;
});
return cell;
}
</code></pre>
<p>我的意思是我已经添加了确实使滚动更好一点的调度部分。但是当我在 <code>UITableView</code> 上快速滚动时,会加载图像和图像过滤器,但滚动时会经常出现颠簸或锯齿状。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>使用 dispatch_async 到其他线程,然后在完成时更新。 </p>
<pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
CIFilter *gaussianBlurFilter = ;
;
] forKey:kCIInputImageKey];
;
CIImage *outputImage = ;
CIContext *context = ;
CGRect rect = ;
rect.origin.x += (rect.size.width- bgPicture.size.width ) / 2;
rect.origin.y += (rect.size.height - bgPicture.size.height) / 2;
rect.size = bgPicture.size;
CGImageRef cgimg = ;
UIImage *image = ;
CGImageRelease(cgimg);
dispatch_async(dispatch_get_main_queue(), ^{
cell.bgP.image = image;
});
});
</code></pre></p>
<p style="font-size: 20px;">关于ios - CIFilter减慢滚动,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/22675275/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/22675275/
</a>
</p>
页:
[1]