Introduced:
A more complete picture browser, high imitation of Sina Weibo image browsing effect, features include: Download browse the Internet pictures, click Thumbnails full screen display pictures, when loading a larger picture will appear a circular progress bar, swipe to browse all the pictures, save the pictures to the local album, GIF picture playback and so on. And just a few lines of code to add the image browser function.
Project Address: http://code4app.com/ios/Quick Integration Picture Browser/525e06116803fa7b0a000001
Use:
for(inti =0; i<3; i++) {Uiimageview*img =[[Uiimageview alloc]init]; Img.tag=i; //Click the Add gestureUITapGestureRecognizer *singletapgesturerecognizer =[[UITapGestureRecognizer alloc]initwithtarget:self Action: @selector (Tapphoto:)]; [Singletapgesturerecognizer setnumberoftapsrequired:1]; [img Addgesturerecognizer:singletapgesturerecognizer];//This is a very important line. ImageView cannot be interacted by defaultimg.userinteractionenabled =YES; [img Setcontentmode:uiviewcontentmodescaleaspectfill]; Img.clipstobounds=YES; [Cdutils Displayiconimagewithurl:model.photos[i] imageview:img]; Img.frame= CGRectMake ((([UIScreen mainscreen].bounds.size.width-2)/3+1) *i,0, ([UIScreen mainscreen].bounds.size.width-2)/3, ([UIScreen mainscreen].bounds.size.width-2)/3); [Self.imagepicview addsubview:img]; }
/** * Monitor the image click*/- (void) Tapphoto: (UITapGestureRecognizer *) recognizer{//1. Create a picture browserMjphotobrowser *brower =[[Mjphotobrowser alloc] init]; //2. Tell the picture browser to show all picturesNsmutablearray *photos =[Nsmutablearray array]; for(inti =0; i < Self.picAry.count; i++) { //passing data to the browserMjphoto *photo =[[Mjphoto alloc] init]; Photo.url=[Nsurl Urlwithstring:self.picary[i]]; NSLog (@"%@", Photo.url); Photo.srcimageview= (Uiimageview *) Recognizer.view;//set the source of which one uiimageview[photos Addobject:photo]; } Brower.photos=photos; //3. Set the default display of the picture indexBrower.currentphotoindex =Recognizer.view.tag; //4. Display browser[Brower show];}
To include these two header files:
#import "MJPhoto.h"
#import "MJPhotoBrowser.h"
Quick integration with picture browser quick Integration Picture Browser->mjphotobrowser use