您好,当使用前缀“#”完成时,表格出现但为空白。
这是相关的代码块:
class types:
class Chat:MessagesViewController, MessagesDataSource, MessagesLayoutDelegate, MessagesDisplayDelegate,InputBarAccessoryViewDelegate,AutocompleteManagerDataSource, AutocompleteManagerDelegate
自动完成变量:
open lazy var autocompleteManager: AutocompleteManager = { [unowned self] in
let manager = AutocompleteManager(for: self.messageInputBar.inputTextView)
manager.delegate = self
manager.dataSource = self
return manager
}()
用于自动完成的 viewdidload:
autocompleteManager.register(prefix: "#", with: mentionTextAttributes)
autocompleteManager.maxSpaceCountDuringCompletion = 1
以下是自动完成的不同方法,所有这些方法都被调用,我们可以看到打印的内容,除了我猜是问题的一个:
调用:
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
}
未调用和发出:
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
}
谁能给点建议 谢谢