Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep getting message input bar delegate ambiguous for type lookup in this context #27

Open
lordKaos11 opened this issue Jun 10, 2019 · 3 comments

Comments

@lordKaos11
Copy link

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)
}

}

@lordKaos11
Copy link
Author

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.."

@isupremedyou
Copy link

@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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@isupremedyou @lordKaos11 and others