ASCellNode内部错误显示水平布局

时间:2018-01-10 14:54:23

标签: ios swift asyncdisplaykit

我使用AsyncDisplayKit编写了这段代码:

override open func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {

    let horizonTitleDate = ASStackLayoutSpec(direction: .horizontal, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [title,space, datetime])
    let verticalMess = ASStackLayoutSpec(direction: .vertical, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [horizonTitleDate, desc])
    let horizonMess = ASStackLayoutSpec(direction: .horizontal, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [avatar, verticalMess])


    //desc.style.width = ASDimensionMake(constrainedSize.max.width - 100)
    desc.style.alignSelf                 = .stretch
    desc.style.flexGrow                  = 1.0
    desc.style.flexShrink                  = 1.0
    verticalMess.style.alignSelf         = .stretch
    verticalMess.style.flexGrow          = 1.0
    horizonTitleDate.style.alignSelf     = .stretch
    let insets  = UIEdgeInsetsMake(5, 5, 5, 5)
    return ASInsetLayoutSpec(insets: insets, child: horizonMess)

}

我得到了这个:

enter image description here

正如您所看到的,黄色TextNode比cellNode大,并且不会变成2行,在纵向模式下看起来像这样:

enter image description here

如果我只绘制没有头像的垂直布局,我会获得正确的视图:

enter image description here

出了什么问题?谢谢!

1 个答案:

答案 0 :(得分:2)

Service Account JSON key file path我没有看到flexShrink。尝试添加以下行:

verticalMess