【问题标题】:Can't implement required methods of JSQMessagesViewController Swift 3无法实现 JSQMessagesViewController Swift 3 所需的方法
【发布时间】:2017-04-29 18:47:27
【问题描述】:

我正在尝试在我的Swift 3 项目中使用JSQMessagesVC。它是通过可可豆荚安装的,一切看起来都很好。问题是我无法实现 collectionView 方法并且不断出错。谁能帮帮我?

导入 UIKit 导入 JSQMessagesViewController 类 ChatViewController: JSQMessagesViewController { var 消息 = [JSQMessage]() 覆盖 func viewDidLoad() { super.viewDidLoad() collectionView!.delegate = self collectionView!.dataSource = self collectionView!.collectionViewLayout.incomingAvatarViewSize = CGSize.zero collectionView!.collectionViewLayout.outgoingAvatarViewSize = CGSize.zero } 覆盖 func collectionView(_ collectionView: JSQMessagesCollectionView, messageDataForItemAt indexPath: IndexPath) -> JSQMessageData { 返回消息[indexPath.item] } 覆盖 func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 返回messages.count } 覆盖 func collectionView(_ collectionView: JSQMessagesCollectionView!, messageBubbleImageDataForItemAt indexPath: IndexPath!) -> JSQMessageBubbleImageDataSource! { 让消息 = 消息[indexPath.item] // 1 if message.senderId == senderId { // 2 返回传出的BubbleImageView } 其他 { // 3 返回传入的BubbleImageView } } 覆盖 func collectionView(_ collectionView: JSQMessagesCollectionView!, avatarImageDataForItemAt indexPath: IndexPath!) -> JSQMessageAvatarImageDataSource! { 返回零 } 懒惰的 var 传出BubbleImageView:JSQMessagesBubbleImage = self.setupOutgoingBubble() 懒惰的 var incomingBubbleImageView: JSQMessagesBubbleImage = self.setupIncomingBubble() 私有函数 setupOutgoingBubble() -> JSQMessagesBubbleImage { 让 bubbleImageFactory = JSQMessagesBubbleImageFactory() return bubbleImageFactory!.outgoingMessagesBubbleImage(with: UIColor.jsq_messageBubbleBlue()) } 私有函数 setupIncomingBubble() -> JSQMessagesBubbleImage { 让 bubbleImageFactory = JSQMessagesBubbleImageFactory() return bubbleImageFactory!.incomingMessagesBubbleImage(with: UIColor.jsq_messageBubbleLightGray()) } // 覆盖 func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { // //你的逻辑在这里 // } }

【问题讨论】:

  • 请告诉我们您遇到了什么错误
  • 即使实现了我无法摆脱这些消息的方法。我正在尝试在 raywenderlich.com/140836/firebase-tutorial-real-time-chat-2 上学习 Raywenderlich 教程
  • 您使用的是最新版本的 JSQMessagesViewController 吗?
  • 是的,版本 7.3.4,我也在使用其他工具:使用 Crashlytics (3.8.3) 使用 Fabric (1.6.11) 使用 Firebase (3.11.0) 使用 FirebaseAnalytics (3.6.0) ) 使用 FirebaseCore (3.4.6) 使用 FirebaseDatabase (3.1.1) 使用 FirebaseInstanceID (1.0.8) 使用 FirebaseMessaging (1.2.1) 使用 GoogleInterchangeUtilities (1.2.2) 使用 GoogleSymbolUtilities (1.1.2) 使用 GoogleToolboxForMac (2.1.0)安装 JSQMessagesViewController (7.3.4) 安装 JSQSystemSoundPlayer (2.0.1)
  • pod 'JSQMessagesViewController' 你是用同一个pod安装的吗?

标签: ios swift3 jsqmessagesviewcontroller


【解决方案1】:

我在编译期间使用脚本来检测一些标签(TODO、FIXME 和 ERROR)。所以,我结合了错误的方法签名和脚本错误检测。

TAGS="TODO:|FIXME:" 错误标签=“错误:” 查找 "${SRCROOT}" (-name ".h" -or -name ".m" -or -name ".swift" ) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).\$|($ERRORTAG).*\$" | perl -p -e "s/($TAGS)/ 警告:\$1/" | perl -p -e "s/($ERRORTAG)/ 错误:\$1/"

【讨论】:

  • 问题已解决。
  • 您好,您的问题是如何解决的。
  • 我已经重写了 TODO 脚本而没有 ERRORTAG。 TAGS="TODO:|FIXME:" find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ 警告:\$1/"
  • 你能不能结束这个问题。
猜你喜欢
  • 2017-09-13
  • 2016-05-05
  • 2016-02-22
  • 1970-01-01
  • 1970-01-01
  • 2013-02-15
  • 1970-01-01
  • 1970-01-01
  • 2021-12-24
相关资源
最近更新 更多