The implementation of the simple picture browser in the UI Foundation article-ios

Source: Internet
Author: User

1 //2 3 //HYVIEWCONTROLLER.M4 5 //01-Image Browser Review6 7 //8 9 //Created by Apple on 15-4-10.Ten  One //Copyright (c) 2015 Apple. All rights reserved. A  - // -  the   -  - #import "HYViewController.h" -  +   -  + @interfaceHyviewcontroller () A  at-(ibaction) last; -  --(ibaction) next; -  - /** Display the number of pictures*/ -  in@property (Weak, nonatomic) Iboutlet UILabel *numlable; -  to /** Show Pictures*/ +  -@property (Weak, nonatomic) Iboutlet Uiimageview *MyImage; the  * /** Display the description of the picture*/ $ Panax Notoginseng@property (Weak, nonatomic) Iboutlet UILabel *desclable; -  the /** Show the status of the button*/ +  A@property (Weak, nonatomic) Iboutlet UIButton *lastbtn; the  +@property (Weak, nonatomic) Iboutlet UIButton *nextbtn; -  $   $  - /** Collection of picture data*/ -  the@property (nonatomic,strong) Nsarray *Arrayimage; - Wuyi /** Record the index of the picture display*/ the  -@property (nonatomic,assign)intindex; Wu  - @end About  $   -  - @implementationHyviewcontroller -  A /** Lazy loading of data*/ +  the-(Nsarray *) Arrayimage -  $ { the  the     if(_arrayimage==Nil) the  the     { -  in         //First time loading the  the         //Initializing Data About  the         //1. Use Mainboundle to access any resource on the mobile resource bundle the  theNSBundle *bdle=[NSBundle Mainbundle]; +  -         //2. Get the full path the BayiNSString *path= [Bdle pathforresource:@"Changedata"OfType:@"plist"]; the  the         //3. Read resources under the full path -  -_arrayimage=[Nsarray Arraywithcontentsoffile:path]; the  the     } the  the      -  the     return_arrayimage; the  the }94  the   the  the //This method is called when the controller's view initialization is complete98  About- (void) Viewdidload - 101 {102 103 [Super Viewdidload];104  the [self changedata];106 107 108 }109  the  111  the /** Changes in data*/113  the-(void) Changedata the  the {117 118     //1. Change the serial number119  -Self.numlable.text=[nsstring stringWithFormat:@"%d/%d", self.index+1, Self.arrayimage.count];121 122     //2. Remove the array of values in the dictionary array name [index subscript]123 124Nsdictionary *dectimage=Self.arrayimage[self.index]; the 126     //3. Change the picture127  -Self.myimage.image=[uiimage imagenamed:dectimage[@"icon"]];129  the     //4. Change the description131  theself.desclable.text=dectimage[@"desc"];133 134     //5. Change the state of the button135 136Self.lastbtn.enabled= (self.index!=0);137 138Self.nextbtn.enabled= (self.index!=self.arrayimage.count-1);139  $ }141 142  143 144 /** Show Previous picture*/145 146-(ibaction) last147 148 {149  Maxself.index--;151  the [self changedata];153 154     155 156 } 157 158 /** Show Next picture*/159  the-(ibaction) Next161 162 {163 164self.index++;165 166 [self changedata];167 168 }169  the @end171 172 173 174 //Personal Summary: Deferred load design, use of nsboundle, use of plist files

The implementation of the simple picture browser in the UI Foundation article-ios

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.