Stanford iOS7 Open Class 4-6 notes and Demo, Stanford ios7 Open Class 4-6

Source: Internet
Author: User

Stanford iOS7 Open Class 4-6 notes and Demo, Stanford ios7 Open Class 4-6

1. do not misuse the id of the variable type. If it is not careful, it is easy to cause errors during program execution, because the compiler only checks the type of the variable object during compilation, especially when the type is id, any type of the table can pass the check, but does not detect the method called by the variable object. In this way, when the class of the object does not contain the called method written, It is compiled and passed, however, an error is reported only when the program is running.

2. briefly introduces the set and font of the framework.

3. NSAttributedString can be used to enrich the font styles displayed on the screen and set various styles. For details, see the Demo of the Attachment:Http://files.cnblogs.com/colinhou/Attributor.zip

4. For the Storyboard currently recommended by Apple, this article introduces its lifecycle and some precautions.

(1) viewDidLoad. During this process, the storyboard initializes the settings, and the various outputs (IBOutlet) We have set have been initialized, you must perform initialization only once for the entire app, because viewDidLoad is executed only once at the beginning of the program. However, it should be noted that the view is not displayed on the screen at this time, that is, the view size and other information are still uncertain, so it is not suitable for changing the size and size of the view.

(2) viewWillAppear. In this process, the geometric information of the view has been determined and is ready for display. If you need to change the size and animation, you can also execute it here. At the same time, some initialization operations should also be performed here, for example, to update data every time the switch is back, for example, to use it. Each time you switch from another place, there will be a circle at the top, you need to obtain the latest data.

(3) viewWillDisappear, indicating that the view will disappear from the screen immediately. In this case, you need to stop animation and other operations to avoid resource occupation. If you also need to save data or status, in this way, the next time you switch back (viewWillAppear), you can easily continue the previous operation or status.

(4) viewDidAppear and viewDidDisappear are triggered when the view already appears or disappears,

DidReceiveMemoryWarning is triggered when the system memory is insufficient,

ViewWill/DidLayoutSubviews is used to set screen rotation, which will be detailed later.

5. broadcast Mechanism nsicationicationcenter. If you listen to an event and meet certain conditions, you can respond to it and trigger the specified operation. It is similar to the flex message mechanism to listen to or cancel listening to a message.

AddObserver indicates the listener object and observer, that is, who listens to this event. selector indicates the response method, and name indicates the broadcast name, indicating the event to be listened, the object indicates who broadcasts the event and whose event it belongs to. If it is nil, it indicates no matter who it is. Once this broadcast or event occurs, it will be listened to and operated accordingly.

At the same time, you must cancel listening when you stop listening to broadcasts. This is because nsicationicationcenter uses the insecure reference pointer "unsafe retained pointer". If you do not cancel listening, when the listening object does not exist, when the NSNotificationCenter is notified to send a notification, the program crashes. Here we should use a weak pointer to automatically change the pointer to nil, however, to be compatible with iOS5 (the weak type pointer iOS6 is used), "unsafe retained pointer" is still used ".

In addition, we recommend that you cancel listening by specifying the specific information to avoid the possibility of using other broadcasts.

6. describes how to use UINavigationController to manage multiple views. For details, see the Demo in the attachment:Http://files.cnblogs.com/colinhou/Attributor.zip

In addition, if you want to skip other views and directly perform simple functional test and verification on specific views, you can move the start arrow in Interface Builder to the target view and write the test method in the code, after debugging is started, you can directly enter the target View verification function.

Demo effect:




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.