我正在尝试结合 facebook 的 AsyncDisplayKit 和 DMLazyScrollView。移动到下一张/上一张图像时, View 会闪烁,如下所示:
没有 AsyncDisplayKit,这个问题就不会发生。
这是负责获取图像的代码部分:
- (UIViewController *) controllerAtIndex:(NSInteger) index {
if (index > viewControllerArray.count || index < 0) return nil;
id res = [viewControllerArray objectAtIndex:index];
if (res == [NSNull null]) {
UIViewController *contr = [[UIViewController alloc] init];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
ASNetworkImageNode *_mediaNode = [[ASNetworkImageNode alloc] init];
_mediaNode.backgroundColor = ASDisplayNodeDefaultPlaceholderColor();
_mediaNode.URL = [NSURL URLWithString:[imagesUrl objectAtIndex:index]];
_mediaNode.frame = contr.view.bounds;
dispatch_async(dispatch_get_main_queue(), ^{
[contr.view addSubview:_mediaNode.view];
});
});
[viewControllerArray replaceObjectAtIndex:index withObject:contr];
return contr;
}
return res;
}
很高兴知道是否有人解决了这个问题。
最佳答案
开始吧,这是闪烁原因的答案:
When converting an app to use AsyncDisplayKit, a common mistake is to add nodes directly to an existing view hierarchy. Doing this will virtually guarantee that your nodes will flash as they are rendered.
关于ios - AsyncDisplayKit 图像显示闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35604682/