博客> ios列表中的图片缩放、视频缩放
ios列表中的图片缩放、视频缩放
2019-12-07 03:58 评论:0 阅读:618 chizengyang
ios 滚动视图 键盘 聊天 IM 图片缩放

代码地址:https://github.com/Soldoros/SSChat

1.添加AVFoundation.framework系统库

2.引用头文件#import "SSImageGroupView.h"

3.在点击图片或短视频的时候对图片、短视频的数组做处理,有一些必传的参数

#pragma SSChatBaseCellDelegate 点击图片 点击短视频
-(void)SSChatImageVideoCellClick:(NSIndexPath *)indexPath layout:(SSChatMessagelLayout *)layout{

    NSInteger currentIndex = 0;
    NSMutableArray *groupItems = [NSMutableArray new];

    for(int i=0;i<self.datas.count;++i){

        NSIndexPath *ip = [NSIndexPath indexPathForRow:i inSection:0];
        SSChatBaseCell *cell = [_mTableView cellForRowAtIndexPath:ip];
        SSChatMessagelLayout *mLayout = self.datas[I];

        SSImageGroupItem *item = [SSImageGroupItem new];
        if(mLayout.message.messageType == SSChatMessageTypeImage){
            item.imageType = SSImageGroupImage;
            item.fromImgView = cell.mImgView;
            item.fromImage = mLayout.message.image;
        }
        else if (mLayout.message.messageType == SSChatMessageTypeVideo){
            item.imageType = SSImageGroupVideo;
            item.videoPath = mLayout.message.videoLocalPath;
            item.fromImgView = cell.mImgView;
            item.fromImage = mLayout.message.videoImage;
        }
        else continue;

        item.contentMode = mLayout.message.contentMode;
        item.itemTag = groupItems.count + 10;
        if([mLayout isEqual:layout])currentIndex = groupItems.count;
        [groupItems addObject:item];

    }

    SSImageGroupView *imageGroupView = [[SSImageGroupView alloc]initWithGroupItems:groupItems currentIndex:currentIndex];
    [self.navigationController.view addSubview:imageGroupView];

    __block SSImageGroupView *blockView = imageGroupView;
    blockView.dismissBlock = ^{
        [blockView removeFromSuperview];
        blockView = nil;
    };

    //这一段是对聊天界面键盘回收的处理 单独使用媒体缩放功能可以不写
    [self.mInputView SetSSChatKeyBoardInputViewEndEditing];
}

代码地址:https://github.com/Soldoros/SSChat

收藏
0
sina weixin mail 回到顶部