Open AnkurLahiry opened 4 years ago
@AnkurLahiry could you provide some more code please? From what I can see there is nothing wrong with that code.
i.e. where is messageInputBar
defined etc
Sure!
for all (My Project, MessageKit and MessageInputBar) SWIFT_VERSION = 5.0
class ChatViewController: MessagesViewController {
override func viewDidLoad() {
super.viewDidLoad()
prepareMessageChatViewController()
}
private func prepareMessageChatViewController() {
prepareMessageView()
prepareMessageInputBar()
}
private func prepareMessageView() {
messagesCollectionView.messageCellDelegate = self
messagesCollectionView.messagesDataSource = self
messagesCollectionView.messagesLayoutDelegate = self
messageInputBar.delegate = self
messagesCollectionView.messagesDisplayDelegate = self
if let layout = messagesCollectionView.collectionViewLayout as? MessagesCollectionViewFlowLayout {
layout.setMessageIncomingAvatarPosition(.init(vertical: .messageCenter))
layout.setMessageOutgoingAvatarPosition(.init(vertical: .messageCenter))
}
maintainPositionOnKeyboardFrameChanged = true
messagesCollectionView.showsVerticalScrollIndicator = false
}
private func prepareMessageInputBar() {
messageInputBar.setMiddleContentView(messageInputBar.inputTextView, animated: false)
messageInputBar.setRightStackViewWidthConstant(to: 52, animated: false)
let bottomItems = [cameraItem, galleryItem, .flexibleSpace] // some custom items
messageInputBar.setStackViewItems(bottomItems, forStack: .bottom, animated: false)
messageInputBar.sendButton.activityViewColor = GLOBAL_TINT_COLOR
messageInputBar.sendButton.backgroundColor = UIColor.white
messageInputBar.sendButton.layer.cornerRadius = 10
messageInputBar.sendButton.setTitleColor(GLOBAL_TINT_COLOR, for: .normal)
messageInputBar.sendButton.setTitleColor(UIColor.lightGray, for: .highlighted)
messageInputBar.sendButton.setTitleColor(GLOBAL_TINT_COLOR, for: .disabled)
messageInputBar.sendButton
.onSelected { item in
item.transform = CGAffineTransform(scaleX: 1.05, y: 1.05)
}.onDeselected { item in
item.transform = .identity
}
messageInputBar.shouldManageSendButtonEnabledState = true
}
}
While adding image using attachment manager, I found this error message