JSQMessagesViewController 不在聊天中显示气泡图像

JSQMessagesViewController Not showing Bubble Image in Chat

我在 objective-c 中的项目使用 JSQMessagesViewController 进行 firebase 聊天,但消息中没有气泡图像。 JSQMessagesViewController 和 Firbase 通过 Pods.

集成

请帮助我。

使用 firebase N JSQMessagesViewController 下载我的聊天应用演示

http://www.mediafire.com/file/a8rb2srsbdv643h/firebasechat.zip/file

创建方法初始化发送方和接收方的颜色,如下面的代码:

  - (JSQMessagesBubbleImage *) setupOutgoingBubble {
    JSQMessagesBubbleImageFactory *bubbleImageFactory = [[JSQMessagesBubbleImageFactory alloc] init];
    JSQMessagesBubbleImage * imgBubble = [bubbleImageFactory outgoingMessagesBubbleImageWithColor:[UIColor blueColor]];//jsq_messageBubbleBlueColor return imgBubble;
    return imgBubble;
}

- (JSQMessagesBubbleImage *) setupIncomingBubble {
    JSQMessagesBubbleImageFactory *bubbleImageFactory = [[JSQMessagesBubbleImageFactory alloc] init];
    JSQMessagesBubbleImage * imgBubble = [bubbleImageFactory outgoingMessagesBubbleImageWithColor:[UIColor greenColor]];//jsq_messageBubbleBlueColor return imgBubble;
    return imgBubble;
}




- (void)setupBubbleColors {
    self.incomingBubbleImageData = [self setupIncomingBubble];
    self.outgoingBubbleImageData = [self setupOutgoingBubble];
}

并在 viewDidLoad 中调用上述方法,如下所示

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    [self setupBubbleColors];

}

和 id JSQMessageBubbleImageDataSource 委托 return 适当的图像如下

- (id<JSQMessageBubbleImageDataSource>)collectionView:(JSQMessagesCollectionView *)collectionView
             messageBubbleImageDataForItemAtIndexPath:(NSIndexPath *)indexPath {
    Message *message = [_messages objectAtIndex:indexPath.row];
    NSLog(@"%@", message.type);
    if(message.isOwnMessageValue) {
        return self.outgoingBubbleImageData;
    }
    else return self.incomingBubbleImageData;
}

输出将如下所示