[iOS base Control-3.3] Picture browser

Source: Internet
Author: User

Requirements: 1. Display the current picture sequence number/Total Picture 2. Show Picture 3. The previous picture, the next picture is converted 4. Show picture description A. How data is loaded 1. Load and Process 2. Use arrays, dictionaries to separate data, and logic 3. Lazy loading initializes the initialization in the getter, Initialize 4 when the required data does not exist. Use plist to store data in external files, stripped data and logic code do not use names with "info", which is confused with system files a. Use NSBundle to get the full path of the phone
1 if(_imagedata = =Nil) {2         //Initializing Data3         //File: Full path4         //Nsboundle: A nsboundle represents a folder5         //use Mainbundle to access any resource on your phone6NSBundle *bundle =[NSBundle Mainbundle];7        8         //get the full path of Imagedata.plist9NSString *path = [Bundle Pathforresource:@"imagedate"OfType:@"plist"];Ten_imagedata =[Nsarray Arraywithcontentsoffile:path]; One}
B. Parsing process of plist file parsing, encapsulation C. Converting pictures
1 #pragmaMark Convert Pictures2- (void) Changedata {3     //1. Set the ordinal title of the current picture4Self.noLabel.text = [NSString stringWithFormat:@"%d/%d", Self.index +1, Self.imageData.count];5     6     //2. Remove the current picture data7Nsdictionary *currentimagedata =Self.imagedata[self.index];8     9     //3. Setting up a pictureTenSelf.iconView.image =[UIImage Imagenamed:currentimagedata[iconkey]]; One      A     //4. Set the picture description -Self.descLabel.text =Currentimagedata[desckey]; -      the     //5. Change the button state -self.previousButton.enabled = (Self.index! =0); -self.nextButton.enabled = (Self.index! = Self.imageData.count-1); - } +  - #pragmaMark, the last one. +-(ibaction) Previous { Aself.index--; at [self changedata]; - } -  - #pragmaMark's next one. --(ibaction) Next { -self.index++; in [self changedata]; - } to @end

[iOS base Control-3.3] Picture browser

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.