1. Interface Analysis
========================================
1> a control that needs to read or modify a property needs to set properties
//Serial number label
//Picture
//Picture Description
//Left button
//Right button
2> need to listen for the object that responds to the event, need to add listening method
//Left button
//Right button
2. Hand code lazy Loading steps to create a control
========================================
1> Define control properties, note: The property must be strong, the sample code is as follows:
@property (nonatomic, strong) Uiimageview *icon;
2> lazy Loading in the getter method of the property, the sample code is as follows:
-(Uiimageview *) icon
{
if (!_icon) {
//Calculate positional parameters
cgfloat Imagew =;
cgfloat ImageX = (320-imagew)/2;
cgfloat Imageh =;
CGFloat imagey = n;
//Materialized image View
_icon = [[Uiimageview alloc] Initwithframe:cgrectmake (ImageX, Imagey, Imagew, Imageh)];
//Add image views to the main view
[self. View Addsubview:_icon];
}
return _icon;
}
Benefits of using lazy loading:
1> does not have to write all the code of the created object inViewdidloadmethod, the code is more readable
2> each control'sGetterEach of the methods is responsible for the respective instantiation, the code is independent of each other, loosely coupled
3. Using the Plist file
========================================
Purpose of using the Plist file: separating data from code
Loading method:
nsstring *path = [[NSBundle mainbundle] pathforresource:@ "ImageData" oftype:@ "plist"];
_imagelist = [Nsarray Arraywithcontentsoffile:path];
Hint: The file word usually appears in the method, usually need to pass the full path of the files as parameters
IOS Photo Browser summary (thought steps)