gpt4 book ai didi

ios - AsyncDisplayKit 图像显示闪烁

转载 作者:行者123 更新时间:2023-11-29 01:12:14 31 4
gpt4 key购买 nike

我正在尝试结合 facebook 的 AsyncDisplayKit 和 DMLazyScrollView。移动到下一张/上一张图像时, View 会闪烁,如下所示:

Display blinks

没有 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.

async display kit docs

关于ios - AsyncDisplayKit 图像显示闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35604682/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com