Strong: Generic Object Weak:ui Control
#define Iconkey @ "icon"
#define DESCKEY @ "desc"
#import "ViewController.h"
@interface Viewcontroller ()
-(ibaction) previous;
-(ibaction) next;
@property (Weak, nonatomic) Iboutlet UIButton *previousbtn;
@property (Weak, nonatomic) Iboutlet UIButton *nextbtn;
@property (Weak, nonatomic) Iboutlet UILabel *nolabel;
@property (Weak, nonatomic) Iboutlet Uiimageview *iconview;
@property (Weak, nonatomic) Iboutlet UILabel *desclabel;
The record is currently showing the first few pictures
@property (nonatomic, assign) int index;
Picture data collection
@property (nonatomic, strong) Nsarray *imagedata;
@end
@implementation Mjviewcontroller
-(void) viewdidload
{
[Super Viewdidload];
[Self changedata];
}
-(Nsarray *) imageData
{
if (_imagedata = = nil) {//Never initialized
Initializing data
Nsmutabledictionary *image1 = [Nsmutabledictionary dictionary];
Image1[iconkey] = @ "Biaoqingdi";
Image1[desckey] = @ "In front of him, other god horse expression is weak!" ";
Nsmutabledictionary *image2 = [Nsmutabledictionary dictionary];
Image2[iconkey] = @ "Wangba";
Image2[desckey] = @ "Brother Why choose Eighth";
Nsmutabledictionary *image3 = [Nsmutabledictionary dictionary];
Image3[iconkey] = @ "Bingli";
Image3[desckey] = @ "This is also cruel";
Nsmutabledictionary *image4 = [Nsmutabledictionary dictionary];
Image4[iconkey] = @ "Chiniupa";
Image4[desckey] = @ "Chiniupa";
Nsmutabledictionary *image5 = [Nsmutabledictionary dictionary];
Image5[iconkey] = @ "Danteng";
Image5[desckey] = @ "Pro, can you change your screen name?" Haha ";
Nsmutabledictionary *image6 = [Nsmutabledictionary dictionary];
Image6[iconkey] = @ "Chiniupa";
Image6[desckey] = @ "new data";
_imagedata = @[image1, Image2, Image3, Image4, Image5];
}
return _imagedata;
}
#pragma mark changes the data
-(void) Changedata
{
1. Change the data
Self.noLabel.text = [NSString stringwithformat:@ "%d/%d", Self.index + 1, Self.imageData.count];
2. Remove the dictionary data for index
Nsdictionary *imagedict = Self.imagedata[self.index];
3. Setting up a picture
Self.iconView.image = [UIImage Imagenamed:imagedict[iconkey]];
4. Settings description
Self.descLabel.text = Imagedict[desckey];
2. Change the button state
self.previousBtn.enabled = (Self.index! = 0);
self.nextBtn.enabled = (Self.index! = self.imagedata.count-1);
}
#pragma mark, the last one.
-(ibaction) Previous {
1. Reducing the Index
self.index--;
2. Change the data
[Self changedata];
}
#pragma Mark's next one.
-(ibaction) Next {
1. Add index
self.index++; 0
2. Display the corresponding content according to the index
[Self changedata];
}
@end
IOS--Image Browser 2 (use Nsdictionary to store data)