Ios Quickblox以WhatsApp格式打开图像

Ios Quickblox以WhatsApp格式打开图像,ios,uicollectionview,quickblox,Ios,Uicollectionview,Quickblox,如何在图像预览后按WhatsApp的方式打开图像 QuickBlox示例演示的代码 新的quickblox api图像附件工作正常,但当我单击图像时,它并没有打开。 我试过这样做: - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 我正在UICollectionView单元格中使用此方法进行图像单击,但它不起作用 完整的方法代码:

如何在图像预览后按WhatsApp的方式打开图像

QuickBlox示例演示的代码

新的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];
                }
            }
        }];
    }
}
}
-(void)collectionView:(QMChatCollectionView*)collectionView配置单元格:(UICollectionViewCell*)indexPath的单元格:(NSIndexPath*)indexPath
{
[super collectionView:collectionView configureCell:cell forIndexPath:indexPath];
[(QMChatCell*)单元格容器视图].highlightColor=[UIColor-colorWithWhite:0.5 alpha:0.5];
if([cell isKindOfClass:[QMChatOutgoingCell类]]| |[cell isKindOfClass:[QMChatAttachmentOutgoingCell类]]){
[(QMChatIncomingCell*)单元格容器视图].bgColor=[UIColor颜色与红色:0绿色:121.0f/255.0f蓝色:1阿尔法:1.0f];
}else if([cell isKindOfClass:[QMChatIncomingCell类]]| |[cell isKindOfClass:[QMChatAttachmentIncomingCell类]])){
[(QMChatOutgoingCell*)单元格容器视图].bgColor=[UIColor-color-withred:231.0f/255.0f-green:231.0f/255.0f-blue:231.0f/255.0f-alpha:1.0f];
}
if([cell conformsToProtocol:@协议(QMChatAttachmentCell)]){
QBChatMessage*message=[self-messageForIndexPath:indexPath];
如果(message.attachments!=nil){
QBChatAttachment*附件=message.attachments.firstObject;
NSMutableArray*keystemove=[NSMutableArray];
N分子*枚举数=[self.attachmentCells键枚举数];
NSString*existingAttachmentID=nil;
while(existingAttachmentID=[enumerator nextObject]){
UICollectionViewCell*cachedCell=[self.attachmentCells objectForKey:existingAttachmentID];
if([cachedCell isEqual:cell]){
[keystemove addObject:existingAttachmentID];
}
}
for(NSString*密钥插入密钥删除){
[self.attachmentCells removeObjectForKey:key];
}
[self.attachmentCells setObject:cell-forKey:attachment.ID];
[(UICollectionViewCell*)单元格setAttachmentID:attachment.ID];
__弱类型(自我)弱自我=自我;
//正在从聊天室附件服务获取图像。
[[ServicesManager实例].chatService.chatAttachmentService getImageForAttachmentMessage:消息完成:^(N错误*错误,UIImage*图像){
//
__typeof(self)strongSelf=weakSelf;
if([(UICollectionViewCell*)单元格附件ID]!=attachment.ID)返回;
[strongSelf.attachmentCells removeObjectForKey:attachment.ID];
如果(错误!=nil){
[SVProgressHUD:error.localizedDescription];
}否则{
如果(图像!=nil){
[(UICollectionViewCell*)单元格设置AttachmentImage:image];
[细胞更新应变];
}
}
}];
}
}
}
但在新的Quickblox api中,图像并没有打开
onClick


我也被这件事困住了。我回答得太晚了,但这可能会帮助其他人面对同样的问题

有两个不同的单元格用于
输入ChatAttachmentMessage
输出ChatAttachmentMessage
。要处理这些问题,
QMChatCell
提供委托。您只需将委托设置为类并重写以下方法:

- (void)chatCellDidTapContainer:(QMChatCell *)cell;
此方法处理单元上的抽头。您需要检查点击的单元格是否为附件消息,然后相应地传递图像

您可以在Github上查询此问题