ios - AsyncDisplayKit 图像显示闪烁

标签 ios asyncdisplaykit

我正在尝试结合 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/

相关文章:

iphone - UITapGestureRecognizer 在 UIImageView 中不工作

ios - Swift 中的 Target-Action 参数问题

ios - 推送通知 Json 中 "Content-available"的用途?

ios - 在 iTunes Connect 中,取消 Pending Developer Release 中的版本并上传新版本时,应用程序版本可以相同吗?

ios - 如何将返回类型表达为类的实例,该类也可以快速确认协议(protocol)

swift - 如何将 ASTextNode 与 TTTAttributedLabel 一起使用

swift - 有没有办法在 ASCollectionNode 水平滚动上加载更多内容时插入新项目

ios - 如何在 AsyncDisplayKit 中为 AsTableNode 创建框架?