MessageInputBar
MessageInputBar copied to clipboard
keep getting message input bar delegate ambiguous for type lookup in this context
import UIKit import MessageKit import MessageInputBar
class newViewController: MessagesViewController {
var messages: [Message] = []
var member: Member!
override func viewDidLoad() {
super.viewDidLoad()
member = Member(name: "bluemoon", color: .blue)
messagesCollectionView.messagesDataSource = self
messagesCollectionView.messagesLayoutDelegate = self
messagesCollectionView.messagesDisplayDelegate = self
messagesCollectionView.messageCellDelegate = self as? MessageCellDelegate
// Do any additional setup after loading the view.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
extension newViewController: MessagesDataSource { func currentSender() -> SenderType { return Sender(id: member.name, displayName: member.name)
}
func numberOfSections(
in messagesCollectionView: MessagesCollectionView) -> Int {
return messages.count
}
func messageForItem(
at indexPath: IndexPath,
in messagesCollectionView: MessagesCollectionView) -> MessageType {
return messages[indexPath.section]
}
func messageTopLabelHeight(
for message: MessageType,
at indexPath: IndexPath,
in messagesCollectionView: MessagesCollectionView) -> CGFloat {
return 12
}
func messageTopLabelAttributedText(
for message: MessageType,
at indexPath: IndexPath) -> NSAttributedString? {
return NSAttributedString(
string: message.sender.displayName,
attributes: [.font: UIFont.systemFont(ofSize: 12)])
}
}
extension newViewController: MessagesLayoutDelegate { func heightForLocation(message: MessageType, at indexPath: IndexPath, with maxWidth: CGFloat, in messagesCollectionView: MessagesCollectionView) -> CGFloat {
return 0
}
}
extension newViewController: MessagesDisplayDelegate { func configureAvatarView( _ avatarView: AvatarView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
let message = messages[indexPath.section]
let color = message.member.color
avatarView.backgroundColor = color
}
}
extension newViewController: MessageInputBarDelegate { func messageInputBar( _ inputBar: MessageInputBar, didPressSendButtonWith text: String) {
let newMessage = Message(
member: member,
text: text,
messageId: UUID().uuidString)
messages.append(newMessage)
inputBar.inputTextView.text = ""
messagesCollectionView.reloadData()
messagesCollectionView.scrollToBottom(animated: true)
}
}
this all started when all the sudden my send button would do nothing. it would not even register.
now its saying the "ambiguous for type lookup.."
@lordKaos11, I'm sorry but you will need to provide more information. Posting an entire file's contents with a single line description makes it hard to understand what you are trying to do.
Can you please specify which line you are having the error on and paste that code snippet?