iOS development: loading, sliding browsing a large number of picture solutions

Source: Internet
Author: User

To share a personal photo album today, read load, slide through a lot of picture solutions, I want to emphasize that programming ideas are not about platform limitations.

I'd like to elaborate on what happens in the short 1 seconds (and the next few seconds) after clicking on any small thumbnail in the thumbnail interface and into the big picture Full-screen browsing interface.

General thinking Process

After clicking on any small image,

1. First make ScrollView frame: size 2 ScrollView, small for gesture scaling single picture, large horizontal loading all photos in turn

2. After making good scrollview frame, load photos

3. All ready to jump page renders to the user selection of the larger image

Load the picture This step, if the album within 10 photos, then there is no technical challenge, but if it is 300 photos? A direct crash? or let the user wait for loading? Time tight task, this step needs to split and optimization.

ScrollView Framework needs to understand the next API, and then move the brain, here is a little trick, many people ask me how to achieve the black space between photos and photos, hehe, put down the code:

#define PADDING-(Nsinteger) Loadphotos {//clear before photo for (UIView *v in [_scrollview subviews])    
    {[v Removefromsuperview];    
    } workingframe = [[UIScreen mainscreen]bounds];    
            
    workingframe.origin.x = PADDING;    
        for (int i = 0; i < int_total i++) {CGRect frame = workingframe;    
        Wqphoto *photoview = [[Wqphoto alloc] initwithframe:frame];    
        [Photoview setscroller:self];    
        
        [Photoview setindex:i];    
        Wqalbumphoto *photo = [Albumobject._photos objectatindex:i];    
        [Photo Cleanthumbnail];    
            if (i = = int_current) {//loaded original image [Photoview setImage:photo.oriImage];    
        [Photoview Setisload:yes]; }else if (int_current-10 < i && i < Int_current + 10) {//loading the left and right proximity thumbnails [Photoview set    
        Image:photo.thumbnail4view]; } [_SCROLLVIew Addsubview:photoview];    
    workingframe.origin.x = workingframe.origin.x + 2 * PADDING + workingFrame.size.width; //Implementation scrollable [_scrollview Setcontentsize:cgsizemake (workingframe.origin.x, WorkingFrame.size.hei    
    GHT/2)];    
    [_scrollview setcontentoffset:cgpointmake (360 * int_current, 0)];    
    Load the remaining thumbnails loadthread = [[Nsthread alloc]initwithtarget:self selector: @selector (loadimages) Object:nil];    
return 0; }

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/OS/extra/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.