first, the state of UIButtonNormal (normal state) Ø The default Ø corresponding enumeration constant: UIControlStateNormal highlighted (highlight state) O button is pressed down (finger not released) Ø Corresponding enumeration constants: uicontrolstatehighlighted Disabled (invalid state, unavailable state) Ø If the Enabled property is no, it is in the disable state, the delegate button can not be clicked O The corresponding enumeration constants: Uicontrolstatedisabled
ii. UIButton and Uiimageview• Same point: can display pictures • Different points Øuibutton By default, you can listen to click events, and Uiimageview by default, you can display different pictures in different states Øuibutton can display text, but also can display pictures • How to choose O UIButton: Need to display pictures, click on the picture need to do some specific action Øuiimageview: just need to show the picture, click on the picture do not need to do anythingIii. use of Nsarray and Nsdictionary• When the image content is very long, the "set content according to index" code does not have extensibility, to be changed frequently • In order to change the status quo, you can consider the picture data line saved to an array, the array is placed in an orderly number of dictionaries, a dictionary representing a picture data, including the picture name, picture description
@property (Strong, nonatomic) Nsarray *images;
• Because only the image data needs to be initialized once, it is initialized in the Get method • The way in which attributes are initialized in the Get method, called lazy loading \ Deferred loadingIv. What is a plist file• It is not a reasonable practice to directly write data directly into the code. If the data often change, it is necessary to turn over the corresponding code to modify, resulting in low code extensibility • Therefore, you can consider storing frequently changed data in a file and reading the latest data from the file after the program starts. If you want to change the data, directly modify the data file, without modifying the code • You can typically use a property list file to store data such as Nsarray or nsdictionary, which has an extension of plist and therefore becomes a "plist file"v. Parsing plist files• Follow the code to parse the data in the Plist file Ø Get the full path of the plist file
NSBundle *bundle = [NSBundle mainbundle];
NSString *path = [Bundle pathforresource:@ "ImageData" oftype:@ "plist"];
Ø Load plist file
_images = [Nsarray Arraywithcontentsoffile:path];
-(Nsarray *) images
{
if (_images = = nil) {
NSBundle *bundle = [NSBundle mainbundle];
NSString *path = [Bundle pathforresource:@ "ImageData" oftype:@ "plist"];
_images = [Nsarray Arraywithcontentsoffile:path];
}
return _images;
}
ios--Summary Series Two