zoukankan      html  css  js  c++  java
  • MJPhotoBrowser 用法

    一、使用方法:
     
    #import "MJPhotoBrowser.h"
    #import "MJPhoto.h"
     
    - (void)tapPhoto:(UITapGestureRecognizer *)recognizer
    {
        //1.创建图片浏览器
        MJPhotoBrowser *brower = [[MJPhotoBrowser alloc] init];
       
        //2.告诉图片浏览器显示所有的图片
        NSMutableArray *photos = [NSMutableArray array];
        for (int i = 0 ; i < self.photos.count; i++) {
            Photo *pic = self.photos[i];
            //传递数据给浏览器
            MJPhoto *photo = [[MJPhoto alloc] init];
            photo.url = [NSURL URLWithString:pic.bmiddle_pic];
            photo.srcImageView = self.subviews[i]; //设置来源哪一个UIImageView
            [photos addObject:photo];
        }
        brower.photos = photos;
       
        //3.设置默认显示的图片索引
        brower.currentPhotoIndex = recognizer.view.tag;
       
        //4.显示浏览器
        [brower show];
    }
     
     
    二、我用到的具体实例:
     
    1)腾讯聊天cell中获取第几张照片,并打开图像浏览器
     
    - (void)TecentChatImageCellShouldShowFullScreen:(TecentChatImageCell *)cell
    {
        MJPhotoBrowser *browser = [[MJPhotoBrowseralloc] init];
       
        browser.currentPhotoIndex = [selfgetPicUrl:cell.indexPath.row];//获取播放第几个图片
       
        browser.photos = _localPicMsgArray;//数组中的是MJPhoto对象
        [browser show];
        //当键盘拉起的时候, 需要关闭键盘, 否则图片显示一半
        [selfdoEndEditGesture];
    }
     
    2)方法来返回第几个元素
     
    - (NSInteger)getPicUrl:(NSInteger)dd
    {
        NSInteger c = 0;
        NSInteger d = 0;
        [_localPicMsgArrayremoveAllObjects];
        for (int i=0;i<self.dataSource.count;++i) {
            id model = self.dataSource[i];
            NSInteger type = [NSDictionary_Number_Object_ForKey(model, @"type") integerValue];
            if (type == MESSAGE_TYPE_IMAGE) {
                NSString* imageURL = [model objectForKey:@"imageURLpath"];//远程URLimage
                NSString* imagePath = [model objectForKey:@"path"];//本地URLimage
                MJPhoto *photo = [[MJPhotoalloc] init];
                if (IS_NS_STRING_EMPTY(imageURL)) {
                    //通过本地URL来查找iamge的方法
                    for (IDSPicSendModel *picModel in_localPicImageMsgArray) {
                        if ([picModel.picPathisEqualToString:imagePath]) {
                            photo.image = picModel.picImage;
                            NSLog(@"%@",picModel.picPath);
                            break;
                        }
                    }
                }
                else {
                    //取远程URL方法
                    photo.url = [NSURLURLWithString:imageURL];
                }
                [_localPicMsgArraycl_addObject:photo];
                if (i == dd) {
                    c = d;
                }
                ++d;
            }
        }
        //返回的是第几个图片元素
        return c;
    }
     
     
  • 相关阅读:
    Multipatch的Z值单位问题(三维坐标系和三维坐标转换,极坐标)
    ArcGIS城市地下管网纵横断面分析设计与实现&三维分析之DEM横断面 纵断面 剖面
    ArcScene按照属性进行拉伸Extrusion
    Python 字符串长度和字符串截取函数
    ArcGIS中Interpolater Polygon to Multipatch(3D)用法及原理——多边形转面片
    arcgis删除重复的线段
    ArcGIS如何判断直线图层的两个端点的编码是否与点图层的Name字段是否相等?
    使用ArcEngine创建Multipatch图形
    ArcGIS和VB联合开发
    ArcGIS根据属性创建3D对象
  • 原文地址:https://www.cnblogs.com/firstrate/p/7489500.html
Copyright © 2011-2022 走看看