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/