iOS Learning notes get plist file read data

Source: Internet
Author: User

@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

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.