iOSJC专题ios实用开发技巧

iOS图片浏览器的简单封装-JLPhotoBrowser

2015-12-26  本文已影响6142人  五蕴皆空_

网络图片浏览

使用步骤

    NSMutableArray *photos = [NSMutableArray array];

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

        UIImageView *child = self.imageViews[i];
        //1.创建photo模型
        JLPhoto *photo = [[JLPhoto alloc] init];
        //2.原始imageView
        photo.sourceImageView = child;
        //3.要放大图片的url
        photo.bigImgUrl = self.bigImgUrls[i];
        //标志
        photo.tag = i;

        [photos addObject:photo];

    }

    //1.创建图片浏览器
    JLPhotoBrowser *photoBrowser = [[JLPhotoBrowser alloc] init];
    //2.获取photo数组
    photoBrowser.photos = photos;
    //3.当前要显示的图片
    photoBrowser.currentIndex = (int)tap.view.tag;
    [photoBrowser show];
效果图 效果图

本地相册访问

使用步骤

    //1.检查相册权限
    [[JLAssetsLibrary shareAssetsLibrary] checkAuthorizationStatus:^(BOOL isAuthorized) {
        
        if (isAuthorized) {//允许访问相册
             //2.生成相册控制器
            JLNavigationController *nav = [JLNavigationController navigationAlbumControllerWithDelegate:self];
            [self presentViewController:nav animated:YES completion:NULL];
            
        }else{//不允许访问
            
            UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:@"未能取得相册访问权限" message:nil delegate:nil cancelButtonTitle:@"我知道了" otherButtonTitles: nil];
            [alerView show];
            
        }
        
    }];
#pragma mark - JLReturnImageDelegate

/**
返回选中的图片二进制数组

@param imageDatas 图片数组
*/
- (void)returnImageDatas:(NSArray *)imageDatas{
    //上传等操作
}
效果图 效果图

点击下载源代码

上一篇下一篇

猜你喜欢

热点阅读