@property (nonatomic,strong) Nsarray *pic;//create Array Properties @property (nonatomic,assign)intindex; Create indexed Properties @property (strong, nonatomic) Iboutlet Uiimageview*ImageIcon;//Uiimageview on the list
-(void) viewdidload
{
[Super Viewdidload];
call data method on first load, let index display No. 0 picture data
[Self datainfosoure];
}//----------Lazy Loading---------------(Nsarray *) pic{//Determine if pic has values at each loadif(_pic = =Nil) { //override the Get method of the Pic property//get plist Path search plist file and assign value to pathNSString *path =[[nsbundle Mainbundle] Pathforresource:@"plisticon.plist"Oftype:nil]; //Read FileNsarray * Array =[Nsarray Arraywithcontentsoffile:path]; //assigning data to attributes_pic =Array; } return_pic;}//the previous one-(ibaction) Pre {//Let Index + +self.index--; [Self datainfosoure]; //determine if it is the last, return yes/noSelf.nextsx.enabled =self.index!=self.pic.count-1; //Setting Control DataSelf.presx.enabled= self.index!=0;}//Next One-(ibaction) Next {self.index++; [Self datainfosoure]; Self.nextsx.enabled=self.index!=self.pic.count-1; Self.presx.enabled= self.index!=0;}-(void) datainfosoure{//gets the current image data from the arrayNsdictionary *dict=Self.pic[self.index]; //gets the data that is set to the control on the interfaceSelf.labIcon.text = [NSString stringWithFormat:@"%d,%ld", self.index+1, (unsignedLong) Self.pic.count]; //Use the Image property to set the picture in the picture frameSelf.imageIcon.image = [UIImage imagenamed:dict[@"Icon"]]; //set the title of this pictureSelf.labtitle.text =dict[@"title"];}
iOS Learning notes get plist file read data