ユーザーがメッセージ バブルをタップしたときにアクションを実行するハンドラーを挿入する方法を理解しようとしています。「セルのカスタマイズ」に関する readme のセクションを見つけて、いくつかの異なるアプローチを試しましたが、今のところうまくいきません。これが私が試したことです:
実装:
- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath
私のviewControllerように:
override func collectionView(collectionView: JSQMessagesCollectionView, didTapMessageBubbleAtIndexPath indexPath: NSIndexPath!) {
super.collectionView(collectionView, didTapMessageBubbleAtIndexPath: indexPath)
println("They tapped!")
}
ただし、これは何らかの理由でまったく呼び出されないようです。
私が試した他のことは実装です:
- (UICollectionViewCell *)collectionView:(JSQMessagesCollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
私のView Controllerでは:
override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = super.collectionView(collectionView, cellForItemAtIndexPath: indexPath) as! JSQMessagesCollectionViewCell
let myDelegate = MyJSQMessagesCollectionViewCellDelegate(origDelegate: cell.delegate!)
cell.delegate = myDelegate
return cell;
}
これは呼び出されますが、デリゲートのメソッドは呼び出されません。
JSQMessagesCollectionViewCellDelegateそれで、それが呼び出されるように適切に配置する方法についての提案はありますか? または、メソッドをオーバーライドする最初の試みdidTapMessageBubbleAtIndexPathは適切な方法ですか?
任意の提案をいただければ幸いです。