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