In the company development project, we need to pop up the pictures downloaded from the network and provide the slide display function. Currently using the image browser developed by colleagues, the latter has time to want to optimize. So I went over the image browser code in the previously developed microblog-like project and extracted it to encapsulate the framework.
At present, the function is relatively humble, time is slowly optimized. Expand your local and network pictures and other support.
Github:https://github.com/jakciehoo/hoophotobrowser
Implementation features
1. Set the image address array, get the current selection image from the address, and then show the current picture (you can set the default display of the first few pictures)
2. Provide picture download progress animation, download successful display download picture, download process to give the progress prompt animation, download failure to provide download failure prompt.
3. toolbar display picture information, and provide save to local album function
4. Memory optimized for the code.
Show :
Add to Project
1. The project relies on sdwebimage, so you need to add a sdwebimage framework to your project: Https://github.com/rs/SDWebImage
2. Copy the Hoophotobrowser from the demo to the project.
Calling methods
Hoophotobrowser call method, you can refer to the demo. Here I write the calling code first.
- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.Uiimageview *imageview =[[Uiimageview alloc] init]; Imageview.frame= CGRectMake ( -, -, $, $); Imageview.image= [UIImage imagenamed:@"uc_header_background.jpg"]; [Self.view Addsubview:imageview]; Imageview.userinteractionenabled=YES; UITapGestureRecognizer*tap =[[UITapGestureRecognizer alloc] initwithtarget:self action: @selector (taptoshow:)]; Tap.numberoftapsrequired=1; [ImageView Addgesturerecognizer:tap];}- (void) Taptoshow:(UITapGestureRecognizer *) Tap {Uiimageview*tapview = (Uiimageview *) Tap.view; Nsarray*images = @[@"http://images.asiatravel.com/Hotel/8016/8016facade.jpg", @"http://images.asiatravel.com/Hotel/8016/8016logo.jpg", @"http://images.asiatravel.com/Hotel/8016/8016bathroom.jpg", @"http://images.asiatravel.com/Hotel/8016/8016standard_room.jpg", @"http://images.asiatravel.com/Hotel/8016/8016lobby-cafe.jpg", @"http://images.asiatravel.com/Hotel/8016/8016lobby-reception.jpg", @"http://images.asiatravel.com/Hotel/8016/8016pool.jpg"]; Nsinteger I=0; Nsmutablearray*parray =[Nsmutablearray array]; for(NSString *urlinchimages) {Hoophoto*photo =[[Hoophoto alloc] init]; Photo.url=[Nsurl Urlwithstring:url]; Photo.index=i; Photo.sourceimageview=Tapview; [Parray Addobject:photo]; I++; } Hoophotobrowser*photobrowser =[[Hoophotobrowser alloc] init]; Photobrowser.currentphotoindex=0; Photobrowser.photos=Parray; [Photobrowser show];}
Finally, you are welcome to refer to study. And you are welcome to pay attention to my public number and learn from each other.
My public number: Tintin's coding Diary
Open source A Web image browser Hoophotobrowser