一、使用方法:
 
#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"];//远程URL的image
            NSString* imagePath = [model objectForKey:@"path"];//本地URL的image
            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;
}
 
 

MJPhotoBrowser 用法的更多相关文章

  1. EditText 基本用法

    title: EditText 基本用法 tags: EditText,编辑框,输入框 --- EditText介绍: EditText 在开发中也是经常用到的控件,也是一个比较必要的组件,可以说它是 ...

  2. jquery插件的用法之cookie 插件

    一.使用cookie 插件 插件官方网站下载地址:http://plugins.jquery.com/cookie/ cookie 插件的用法比较简单,直接粘贴下面代码示例: //生成一个cookie ...

  3. Java中的Socket的用法

                                   Java中的Socket的用法 Java中的Socket分为普通的Socket和NioSocket. 普通Socket的用法 Java中的 ...

  4. [转载]C#中MessageBox.Show用法以及VB.NET中MsgBox用法

    一.C#中MessageBox.Show用法 MessageBox.Show (String) 显示具有指定文本的消息框. 由 .NET Compact Framework 支持. MessageBo ...

  5. python enumerate 用法

    A new built-in function, enumerate() , will make certain loops a bit clearer. enumerate(thing) , whe ...

  6. [转载]Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法总结

    本文对Jquery中$.get(),$.post(),$.ajax(),$.getJSON()的用法进行了详细的总结,需要的朋友可以参考下,希望对大家有所帮助. 详细解读Jquery各Ajax函数: ...

  7. 【JavaScript】innerHTML、innerText和outerHTML的用法区别

    用法: <div id="test">   <span style="color:red">test1</span> tes ...

  8. chattr用法

    [root@localhost tmp]# umask 0022 一.chattr用法 1.创建空文件attrtest,然后删除,提示无法删除,因为有隐藏文件 [root@localhost tmp] ...

  9. 萌新笔记——vim命令“=”、“d”、“y”的用法(结合光标移动命令,一些场合会非常方便)

    vim有许多命令,网上搜有一堆贴子.文章列举出各种功能的命令. 对于"="."d"."y",我在无意中发现了它们所具有的相同的一些用法,先举 ...

随机推荐

  1. C 删除字符串1字符串2

    #include<stdio.h> #include<string.h> void main() { char s1[1000],s2[100],b[100]; int i,j ...

  2. 【38.24%】【codeforces 621E】 Wet Shark and Blocks

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. sublime 内容高级搜索

    在发展中经常需要搜索内表面的文件.更好地想找到$video->getTitle() 在该文件中使用的表面.好了,这个时候就需要使用高级搜索功能,的操作,如以下: ctrl+shif+f纽带 例如 ...

  4. 跟我学CMD实战系列之二 ——数据压缩备份

    需求:每天下班时,将本地硬盘上的projects目录压缩为rar文件,文件名中必须含有当天日期信息,例如projects_20070902.rar. 分析:1. 压缩可以调用WinRAR的命令行版本r ...

  5. Clustered filesystem with membership version support

    A computer system with read/write access to storage devices creates a snapshot of a data volume at a ...

  6. VS2015如何自定义类模板、我的模板——原来这么简单!

    在前一段时间忽然想给自己电脑上的vs新建类的时候添加一个自定义个注释,但是在网上搜了很久都是说vs2012之类的方法系统也都是win7.XP之类的独独没有win8的.故此自己不断的尝试修改发现方法如下 ...

  7. Notice: Undefined index: user in D:\phpStudy\WWW\js\ls\lsmc\php\add.php on line 9

    原文:Notice: Undefined index: user in D:\phpStudy\WWW\js\ls\lsmc\php\add.php on line 9 (初用数据库(mysql)做用 ...

  8. exponential family distribution(指数族分布)

    1. exponential family 给定参数 η,关于 x 的指数族分布定义为如下的形式: p(x∣∣η)=h(x)g(η)exp{ηTu(x)} 其中 x 可以为标量也可以为矢量,可以为离散 ...

  9. 1 下载abp 以及 遇到的包管理问题

    我选择的是ef 多页面 不适用系统的module zero模块 项目名为Blog_Solution 遇到一个问题是就是  Castle.LoggingFacility.MsLogging 版本问题 我 ...

  10. Windows中点击“关闭”button发生了什么?

    对于Windows操作,当用户点击"关闭"button时,窗体函数就会收到一个WM_DESTROY消息. 窗体函数应该调用PostQuitMessage(0) 向消息队列插入一个W ...