Quickblox将图像打开为WhatsApp

时间:2015-12-31 07:21:43

标签: ios uicollectionview quickblox

如何打开图像,WhatsApp在图像预览后单击

QuickBlox示例演示代码code link

新的quickblox api图像附件工作正常但是当我点击图像时它没有打开。 我试过这个:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
  

我在UICollectionView单元格中使用此方法进行图片点击但不起作用。

完整的方法代码:

- (void)collectionView:(QMChatCollectionView *)collectionView configureCell:(UICollectionViewCell *)cell forIndexPath:(NSIndexPath *)indexPath
  {
    [super collectionView:collectionView configureCell:cell forIndexPath:indexPath];

    [(QMChatCell *)cell containerView].highlightColor = [UIColor colorWithWhite:0.5 alpha:0.5];

    if ([cell isKindOfClass:[QMChatOutgoingCell class]] || [cell isKindOfClass:[QMChatAttachmentOutgoingCell class]]) {
    [(QMChatIncomingCell *)cell containerView].bgColor = [UIColor colorWithRed:0 green:121.0f/255.0f blue:1 alpha:1.0f];
    } else if ([cell isKindOfClass:[QMChatIncomingCell class]] || [cell isKindOfClass:[QMChatAttachmentIncomingCell class]]) {
    [(QMChatOutgoingCell *)cell containerView].bgColor = [UIColor colorWithRed:231.0f / 255.0f green:231.0f / 255.0f blue:231.0f / 255.0f alpha:1.0f];
    }

   if ([cell conformsToProtocol:@protocol(QMChatAttachmentCell)]) {
    QBChatMessage* message = [self messageForIndexPath:indexPath];
    if (message.attachments != nil) {
        QBChatAttachment* attachment = message.attachments.firstObject;

        NSMutableArray* keysToRemove = [NSMutableArray array];

        NSEnumerator* enumerator = [self.attachmentCells keyEnumerator];
        NSString* existingAttachmentID = nil;
        while (existingAttachmentID = [enumerator nextObject]) {
            UICollectionViewCell* cachedCell = [self.attachmentCells objectForKey:existingAttachmentID];
            if ([cachedCell isEqual:cell]) {
                [keysToRemove addObject:existingAttachmentID];
            }
        }

        for (NSString* key in keysToRemove) {
            [self.attachmentCells removeObjectForKey:key];
        }

        [self.attachmentCells setObject:cell forKey:attachment.ID];
        [(UICollectionViewCell<QMChatAttachmentCell> *)cell setAttachmentID:attachment.ID];

        __weak typeof(self)weakSelf = self;
        // Getting image from chat attachment service.
        [[ServicesManager instance].chatService.chatAttachmentService getImageForAttachmentMessage:message completion:^(NSError *error, UIImage *image) {
            //
            __typeof(self) strongSelf = weakSelf;

            if ([(UICollectionViewCell<QMChatAttachmentCell> *)cell attachmentID] != attachment.ID) return;

            [strongSelf.attachmentCells removeObjectForKey:attachment.ID];

            if (error != nil) {
                [SVProgressHUD showErrorWithStatus:error.localizedDescription];
            } else {
                if (image != nil) {
                    [(UICollectionViewCell<QMChatAttachmentCell> *)cell setAttachmentImage:image];
                    [cell updateConstraints];
                }
            }
        }];
    }
}
}

但是在New Quickblox中,api图像没有打开onClick

enter image description here

1 个答案:

答案 0 :(得分:0)

我也被困在这里。我回答太晚了,但它可能会帮助其他人面临同样的问题。

IncomingChatAttachmentMessageOutgoingChatAttachmentMessage有两个不同的单元格。要处理这些问题,QMChatCell会提供代理。您只需将委托设置为您的类并覆盖以下方法:

- (void)chatCellDidTapContainer:(QMChatCell *)cell;

此方法处理单元格。您需要检查分接的单元格是否为附件消息,然后相应地传递图像。

您可以在QMChatViewController issues上的Github上提及此问题。