2017-06-13 2 views
0

How to overrride mediaViewDisplaySize for a custom media item in JSQMessagesViewController?オーバーライドmediaViewDisplay

私はJSQMessageViewControllerに新たなんだ、上記のトピックを参照してください、私は、カスタムビューを作成し、以下の方法

    を追加するために同じ要件を持っています
  • (ID)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath

コードで実装する方法は分かりますか?

ありがとうございます。

よろしく 次マーカス

答えて

0

は私の実装です:

- (id<JSQMessageData>)collectionView:(JSQMessagesCollectionView *)collectionView messageDataForItemAtIndexPath:(NSIndexPath *)indexPath { 
    ChatMsgEntity *entity = [[self.chattingDatas getDataList] objectAtIndex:indexPath.item]; 
    JSQMessage *md = nil; 

     UIView* containerView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 100, 100)]; 
     containerView.frame = CGRectMake(0.0f, 0.0f, 315.0f, 100.0f); 
     UILabel *label = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, 50, 50)]; 
     label.text = @"vendor name"; 
     [containerView addSubview:label]; 

     md = [[JSQMessage alloc] initWithSenderId:entity.name senderDisplayName:entity.name date:entity.date media:containerView]; 

    return md; } 

が、私は次のようなエラーが発生しました:

*キャッチされない例外が原因アプリ 'NSInvalidArgumentException'、理由を終了: ' - [UIView mediaViewDisplaySize]: インスタンスに送信された認識できないセレクタ0x7fa7fbf0b9e0' *まずスローコールスタック(0 CoreFoundationの0x000000010806034b exceptionPreprocess + 171 objc_exception_throw + 48 2 CoreFoundationの
0x00000001080cff34 1 libobjc.A.dylib
0x000000010721d21e - [NSObjectの(NSObjectの)doesNotRecognizeSelector:] + 132 3 CoreFoundationの0x0000000107fe5c15 ___forwarding_
+ 1013年4 CoreFoundationの0x0000000107fe5798 _CF_forwarding_prep_0 + 120 5 talkm_visitor_sdk 0x0000000106959de3 - [JSQMessagesBubblesSizeCalculator messageBubbleSizeForMessageData:atIndexPath:withLayout:] + 227 6
talkm_visitor_sdkの0x00000001069cea5c - [JSQMessagesCollectionViewFlowLayout messageBubbleSizeForItemAtIndexPath:] + 268 7 libC++ abi.dylib: NSException型のキャッチされない例外で終了する

関連する問題