使用MessagesLayoutDelegate迁移到1.0.0 MessageKit Cocoapod

时间:2018-10-01 02:17:49

标签: ios messagekit

当我尝试升级到MessageKit v1.0.0时,出现以下错误:

enter image description here

我很想知道将其转换为新API的迁移路径。谢谢!

1 个答案:

答案 0 :(得分:0)

似乎LabelAlignment类进行了更改。它不再具有预定义的.messageLeading,而是具有textAlignment的属性作为LabelAlignment对象的一部分。如果按住Command并单击LabelAlignment,则可以看到其定义。

public var textAlignment: NSTextAlignment
public var textInsets: UIEdgeInsets

因此,您所需要做的就是调整对新构造函数的调用。

func cellTopLabelAlignment(for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) -> LabelAlignment {
    if isFromCurrentSender(message: message) {
        return LabelAlignment(textAlignment: NSTextAlignment.left, textInsets: UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10))
    }
    return LabelAlignment(textAlignment: NSTextAlignment.right, textInsets: UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10))
}

如果要找出每个发行版中已完成的所有更改,请查看ChangeLog here

祝你好运