iOS Development UI chapter-a simple Browser viewer program

Source: Internet
Author: User

First, the implementation requirements of the program

1. Requirements

2. Interface Analysis

(1) controls that need to read or modify properties need to set properties

Ordinal label

Image

Picture description

Left button

Right button

(2) need to listen to the object of the response event, need to add a listening method

Left button

Right button

3. Some new properties and methods

3.1

UILabel *headlab=[[uilabel Alloc]initwithframe:cgrectmake (20, 10, 300, 30)]; [   headlab settext:@ "1/5"];     [Headlab settextalignment:nstextalignmentcenter];  Text Center     [Headlab Settextcolor:[uicolor Blackcolor]];

3.2
Click on the Control button, if 5 then the right button fails, if 1, then the left button fails 126     self.leftbtn.enabled= (self.i!=0); 127     self.rightbtn.enabled= (self.i!= 4);


3.3
 The Get method of array 161-(Nsarray *) array162 {163 NSLog (@ "need to get Array"); 164//Instantiate only once 165 if (_array==nil) {166 NSL OG (@ "instanced array"); 167 nsdictionary *[email protected]{@ "name": @ "Biaoqingdi", @ "desc": @ "what expression is weak!" "};168 nsdictionary *[email protected]{@" name ": @" Bingli ", @" desc ": @" case "};169 nsdictionary *[email&nbs p;protected]{@ "name": @ "Wangba", @ "desc": @ "turtle"};170 nsdictionary *[email protected]{@ "name": @ "Chiniupa" @ "des C ": @" Eat steak "};171 nsdictionary *[email protected]{@" name ": @" Danteng ", @" desc ": @" egg ache "};172 [Email pro tected][dict1,dict2,dict3,dict4,dict5];173}174//nsdictionary *[email protected]{@ "name": @ "Biaoqingdi", @ "de SC ": @" what expression is weak! "};175//nsdictionary *[email protected]{@" name ": @" Bingli ", @" desc ": @" case "};176//Nsdictionary *[EMAIL PR otected]{@ "name": @ "Wangba", @ "desc": @ "turtle"};177//nsdictionary *[email protected]{@ "name": @ "Chiniupa" @ "desc" : @ "Eat steak"};178//Nsdictionary *[email protected]{@ "name": @ "Danteng", @ "desc": @ "egg ache"};179//[Email protected][dict1,dict2,dict3,dic t4,dict5];181 return _array;182}

3.4

Using the Plist file

(1) Purpose of using the Plist file: separating data from code

(2) 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

-(Nsarray *) array111 {     NSLog (@ "need to get Array"); 113     //Instantiate only once     if (_array==nil) {         NSString * Path=[[nsbundle Mainbundle] pathforresource:@ "Data" oftype:@ "plist"];117         //array from file get 118        //_array=[ Nsarray arraywithcontentsoffile:path];119         _array=[[nsarray alloc]initwithcontentsoffile:path];120         // Print View Package location 121         NSLog (@ "%@", Path), 122         123        NSLog (@ "instanced array"); 124     }125 126     return _array;127}


4.1

Add

Development ideas:

1. Complete the basic function

2. Consider performance

(1) (Initialize operation, can call change directly)

(2) because you want to control the number and picture two variables, so consider using a dictionary instead of switch

(3) Each click, the dictionary needs to be created once, the efficiency of the underground, you can consider the creation of this part of the initialization method to go, so that only need to create once on the OK.

(4) Consider the drawbacks (the order of the code is very strict)

(5) Lazy loading (load only when needed, then when it is needed, and when the Get method is called)

(6) Come here every time? Inefficient-"Only the first call to the Get method is empty, when the array is instantiated and created, and other times the member variables are returned directly (only once)

Note the point:

1. The Call stack (order) of the method.

2. Use plist: Let the data operation more flexible, the data to go outside, decoupling, so that coupling is not too strong. is actually an XML, which is a special format of XML defined by Apple.

3.bundle-package (Read only)

iOS Development UI chapter-a simple Browser viewer program

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.