mirror of
https://github.com/MessageKit/MessageKit.git
synced 2026-02-06 19:03:19 +00:00
update ChatExample code for AccessoryView to work properly
This commit is contained in:
@@ -328,7 +328,11 @@ extension AdvancedExampleViewController: MessagesDisplayDelegate {
|
||||
func configureAccessoryView(_ accessoryView: UIView, for message: MessageType, at indexPath: IndexPath, in messagesCollectionView: MessagesCollectionView) {
|
||||
// Cells are reused, so only add a button here once. For real use you would need to
|
||||
// ensure any subviews are removed if not needed
|
||||
guard accessoryView.subviews.isEmpty else { return }
|
||||
|
||||
// The following code doesn't work properly. Use forEach method instead.
|
||||
// guard accessoryView.subviews.isEmpty else { return } // not working
|
||||
accessoryView.subviews.forEach{$0.removeFromSuperview()} // works
|
||||
|
||||
let button = UIButton(type: .infoLight)
|
||||
button.tintColor = .primaryColor
|
||||
accessoryView.addSubview(button)
|
||||
|
||||
Reference in New Issue
Block a user