在最近項(xiàng)目中遇到實(shí)現(xiàn)朋友圈的照片查看知允,當(dāng)是自己寫(xiě)了撒蟀,就是在scrollview上加手勢(shì)實(shí)現(xiàn),但是感覺(jué)就是不好温鸽,于是就找了個(gè)第三方保屯,實(shí)現(xiàn)了。
實(shí)現(xiàn)的功能:
1涤垫、單次點(diǎn)擊到照片瀏覽姑尺,在此單次點(diǎn)擊退出瀏覽
2、進(jìn)入照片瀏覽后雙擊放大蝠猬、在此雙擊縮小
3切蟋、捏合放大縮小
4、照片的index顯示
5榆芦、照片的保存到本地沙盒
還有其他功能可以自己發(fā)現(xiàn)柄粹。。匆绣。
請(qǐng)看這塊:其實(shí)就是在集合視圖的點(diǎn)擊方法里面驻右,
1.#import "UIImageView+WebCache.h"
2.#import "SDPhotoBrowser/SDPhotoBrowser.h"(這個(gè)是查看頭文件)
2.在點(diǎn)擊方法中寫(xiě)如下方法,
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
//初始化照片查看
SDPhotoBrowser *photoBrowser = [[SDPhotoBrowser alloc] init];
//遵循代理
photoBrowser.delegate = self;
//傳入第幾個(gè)照片
photoBrowser.currentImageIndex = indexPath.item;
//總共幾個(gè)照片
photoBrowser.imageCount = self.imageArray.count;
//放集合視圖的容器視圖
photoBrowser.sourceImagesContainerView =self.collectionView;
//讓照片查看顯示
[photoBrowser show];
}```
// 返回臨時(shí)占位圖片(即原來(lái)的小圖)
- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index
{
return [UIImage imageNamed:@"placeHoderImage"];
}
// 返回高質(zhì)量圖片的url
-
(NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index {
return self.imageArray[index];
}