一、使用方法:
 
#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. Ruby开发环境

    Windows上Ruby开发环境的配置   最近公司项目上有需要,需要开发一个puppet的自动化工具,这个工具需要操作存储设备上的各种资源,而鉴于puppet不是善于完成这个任务的首选语言,于是我们 ...

  2. Canvas,Matrix的变换顺序

    Canvas的几何变换是倒序的,Matrix是正序. 比如先平移在旋转: canvas.rotate(); canvas.translate(); //translate先执行,rotate后执行 M ...

  3. Android四个基本组件(2)之Service 服务与Content Provider内容提供商

    一.Service 维修: 一Service 这是一个长期的生命周期,没有真正的用户界面程序,它可以被用于开发如监视类别节目. 表中播放歌曲的媒体播放器.在一个媒体播放器的应用中.应该会有多个acti ...

  4. hdu3698 Let the light guide us dp+线段树优化

    http://acm.hdu.edu.cn/showproblem.php?pid=3698 Let the light guide us Time Limit: 5000/2000 MS (Java ...

  5. Android Studio ERROR: x86 emulation currently requires hardware acceleration!报错解决傻瓜教程~

    很早之前就碰到过Android Studio模拟器无法启动的问题,今天终于尝试去解决了下,下面将我解决的方法记录下. 模拟器报错信息为: emulator: ERROR: x86 emulation ...

  6. python下载图片(3)

    # -*- coding: utf-8 -*-"""some function by metaphy,2007-04-03,copyleftversion 0.2&quo ...

  7. C#实现进程内存信息获取

    using System.Collections.Generic;using System.Runtime.InteropServices;using System;using System.Diag ...

  8. linux nano 命令

    linux nano一linux像pico文本编辑软件,功能少.但是,基本能满足要求

  9. Golang写https服务端

    1. 生成私钥openssl genrsa -out key.pem 20482. 生成证书openssl req -new -x509 -key key.pem -out cert.pem -day ...

  10. js 层的显示和隐藏

    <!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"> ...