MJPhotoBrowser使用

1.导入头文件

#import "MJPhotoBrowser.h"
#import "MJPhoto.h"

2.

/**
 *  监听图片的点击
 */
- (void)tapPhoto:(UITapGestureRecognizer *)recognizer
{    
    //1.告诉图片浏览器显示所有的图片
    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];
    }


    //2.显示相册
    MJPhotoBrowser *brower = [[MJPhotoBrowser alloc] init];
    //将存有MJPhoto图片的数组传递给brower
    brower.photos = photos;
    //设置默认显示的图片索引
    brower.currentPhotoIndex = recognizer.view.tag;
    //显示浏览器
    [brower show];
}

你可能感兴趣的:(MJPhotoBrowser使用)