Open Camelot93 opened 2 years ago
Hello, I know that a similar issue has been raised https://github.com/MessageKit/MessageInputBar/issues/7https://github.com/MessageKit/MessageInputBar/issues/7 but it has highlighted a different problem that I am experiencing. When completing it with the prefix "#" the table appears but is blank.
here are the concerned chunk of code :
class types:
class Chat:MessagesViewController, MessagesDataSource, MessagesLayoutDelegate, MessagesDisplayDelegate,InputBarAccessoryViewDelegate,AutocompleteManagerDataSource, AutocompleteManagerDelegate
autocomplete variable:
open lazy var autocompleteManager: AutocompleteManager = { [unowned self] in let manager = AutocompleteManager(for: self.messageInputBar.inputTextView) manager.delegate = self manager.dataSource = self return manager }()
viewdidload for autocomplete:
autocompleteManager.register(prefix: "#", with: mentionTextAttributes) autocompleteManager.maxSpaceCountDuringCompletion = 1
Here are the different methods for autocomplete, all of them are called and we can see what is printed except for one which i guess is the issue:
CALLED:
func autocompleteManager(_ manager: AutocompleteManager, shouldBecomeVisible: Bool) { setAutocompleteManager(active: shouldBecomeVisible) }
func setAutocompleteManager(active: Bool) { let topStackView = messageInputBar.topStackView if active && !topStackView.arrangedSubviews.contains(autocompleteManager.tableView) { topStackView.insertArrangedSubview(autocompleteManager.tableView, at: topStackView.arrangedSubviews.count) topStackView.layoutIfNeeded() } else if !active && topStackView.arrangedSubviews.contains(autocompleteManager.tableView) { topStackView.removeArrangedSubview(autocompleteManager.tableView) topStackView.layoutIfNeeded() } messageInputBar.invalidateIntrinsicContentSize() }
```
func autocompleteManager(_ manager: AutocompleteManager, shouldRegister prefix: String, at range: NSRange) -> Bool { return true }
NOT CALLED AND ISSUE:
func autocompleteManager(_ manager: AutocompleteManager, tableView: UITableView, cellForRowAt indexPath: IndexPath, for session: AutocompleteSession) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: AutocompleteCell.reuseIdentifier, for: indexPath) as? AutocompleteCell else { fatalError("None ") } let users = Users let name = session.completion?.text ?? "" let user = users.filter { return $0.displayName == name }.first cell.imageView?.image = UIImage(named: "art.scnassets/imp.png") cell.textLabel?.attributedText = manager.attributedText(matching: session, fontSize: 15) return cell }
Can anyone please advise Thank you
Hello, I know that a similar issue has been raised https://github.com/MessageKit/MessageInputBar/issues/7https://github.com/MessageKit/MessageInputBar/issues/7 but it has highlighted a different problem that I am experiencing. When completing it with the prefix "#" the table appears but is blank.
here are the concerned chunk of code :
class types:
class Chat:MessagesViewController, MessagesDataSource, MessagesLayoutDelegate, MessagesDisplayDelegate,InputBarAccessoryViewDelegate,AutocompleteManagerDataSource, AutocompleteManagerDelegate
autocomplete variable:
viewdidload for autocomplete:
Here are the different methods for autocomplete, all of them are called and we can see what is printed except for one which i guess is the issue:
CALLED:
func autocompleteManager(_ manager: AutocompleteManager, shouldRegister prefix: String, at range: NSRange) -> Bool { return true }
func autocompleteManager(_ manager: AutocompleteManager, tableView: UITableView, cellForRowAt indexPath: IndexPath, for session: AutocompleteSession) -> UITableViewCell { guard let cell = tableView.dequeueReusableCell(withIdentifier: AutocompleteCell.reuseIdentifier, for: indexPath) as? AutocompleteCell else { fatalError("None ") } let users = Users let name = session.completion?.text ?? "" let user = users.filter { return $0.displayName == name }.first cell.imageView?.image = UIImage(named: "art.scnassets/imp.png") cell.textLabel?.attributedText = manager.attributedText(matching: session, fontSize: 15) return cell }