Ios ui advanced 03, iosui advanced

Source: Internet
Author: User

Ios ui advanced 03, iosui advanced
Navigation Controller

1. The navigation controller always displays the view of the stack top controller.

2. The navigation controller must be used to redirect between interfaces.

3. Calling the pop method does not immediately destroy the current controller.

4. Note that the controller passed in must be the controller in the navigation controller stack.

5. The content of the navigation bar is determined by the stack top controller. A navigation controller has only one navigation bar. Therefore, only one Controller determines who is first displayed on the outermost side and who is the stack top controller.

6. After iOS7, the image of the button on the navigation bar is rendered in blue by default.

7. We do not need to manage the positions of the child controls on the navigation bar. We only need to manage the size.

8. UINavigationItem: a model that determines the content of the navigation bar (content on the left, middle, and right)

10. As long as you see the item in the future, it is usually the model provided by Apple. You only need to modify the model to modify some controls of apple.

1-lifecycle of the controller view

3. viewDidUnload is often used to clear interface data in non-ARC scenarios.

2-data storage 1. plist Storage

1. plist storage, generate a plist file.

2. plist is used to store dictionaries or arrays. plist is used to store dictionaries or arrays.

Note: Plist cannot store custom objects.

3. Obtain the Caches file path in the application sandbox.

// Directory: Which folder to obtain // domainMask: In which range to search, NSUserDomainMask: Search for/expandTilde: whether to expand full path YES: indicates to expand the full path NO: the full path will not be expanded, and the path of the application sandbox will use the Tilde (~) Replace // obtain the Caches folder path NSString * cachePath = NSSearchPathForDirectoriesInDomains (NSCachesDirectory, NSUserDomainMask, YES) [0];

4. Read plist. What type of storage was previously stored and what type of reading was

2. Storage of preference settings
// Storage of preference settings: NSUserDefaults // preference settings are made in the form of a dictionary. Usage and dictionary. // benefits of preference settings: 1. no need to care about the file name // 2. store key-value pairs quickly // 3. directly store Basic Data Types

@ Implementation ViewController

-(IBAction) save :( id) sender {

// Obtain the singleton

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];

// @ "123" key: pwd

[Defaults setObject: @ "123" forKey: @ "pwd"];

// Bool

[Defaults setBool: YES forKey: @ "isOn"];

// Int

[Defaults setInteger: 10 forKey: @ "num"];

}

-(IBAction) read :( id) sender {

// Use the NSUserDefaults Singleton

NSString * pwd = [[NSUserDefaults standardUserDefaults] objectForKey: @ "pwd"];

NSInteger I = [[NSUserDefaults standardUserDefaults] integerForKey: @ "num"];

NSLog (@ "% @ -- % ld", pwd, I );

}

 

3. Archiving

1. NSKeyedArchiver is used for custom object archiving.

// When to call: This method will be called when an object is to be archived. // This function tells apple which attributes of the current object need to be archived-(void) encodeWithCoder :( NSCoder *) acder {[acder encodeObject: _ name forKey: @ "name"]; [acder encodeInt: _ age forKey: @ "age"];} // when to call: This method is called when an object is to be archived. // function: tell apple which attributes of the current object need to be archived // when is initWithCoder called?-(id) initWithCoder (NSCoder *) is called when a file is parsed *) aDecoder {# warning [super initWithCoder] if (self = [super init]) {// solve the file // remember to assign a value to the member attribute _ name = [aDecoder decodeObjectForKey: @ "name"]; _ age = [aDecoder decodeIntForKey: @ "age"];} return self ;}

Related Article

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.