ios – 从JSQMessagesViewController打开图像

前端之家收集整理的这篇文章主要介绍了ios – 从JSQMessagesViewController打开图像前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用 JSQMesssagesViewController构建一个消息传递应用程序.我现在可以使用此图像发送图像,但想点击图像以全屏打开.此功能类似于标准消息传递应用程序,允许您点击图像“气泡”,并捏放大和缩小.有没有人有过使用JSQMessagesViewController做这个的经验?感谢那些可以提供帮助的人!

解决方法

JSQmessage没有处理,但您可以在此方法中使用zoomPopup类添加功能

- (void)collectionView:(JSQMessagesCollectionView *)collectionView didTapMessageBubbleAtIndexPath:(NSIndexPath *)indexPath
{
    JSQMessage *message = [self.messageModelData.messages objectAtIndex:indexPath.row];

    if (message.isMediaMessage) {
        id<JSQMessageMediaData> mediaItem = message.media;

        if ([mediaItem isKindOfClass:[JSQPhotoMediaItem class]]) {

            NSLog(@"Tapped photo message bubble!");

            JSQPhotoMediaItem *photoItem = (JSQPhotoMediaItem *)mediaItem;
            [self popupImage:photoItem.image];
        }
    }
}

- (void) popupImage: (UIImage*)image
{
    UIWindow *window = [[UIApplication sharedApplication] keyWindow];
    UIView *topView = window.rootViewController.view;
    imageView = [[UIImageView alloc] initWithImage:image];

    zoomPopup  *popup = [[zoomPopup alloc] initWithMainview:topView andStartRect:CGRectMake(topView.frame.size.width/2,topView.frame.size.height/2,0)];
    [popup showPopup:imageView];
}

你可以在这里看到zoomPopup:
https://github.com/Tintenklecks/zoomPopup

猜你在找的iOS相关文章