IOS Photo Browser summary (thought steps)

Source: Internet
Author: User

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)

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.