Learning Ios:2

Source: Internet
Author: User

The plan is really not up to the change, week Four or Five due to personal work and personal affairs (and of course, lazy factors,-_-| | ), only Staford lecture 2,3 read, and squeeze time to see "beginning" of "development process" "Designing a User Interface" "Defining the Interaction "A few chapters, did not complete the day a lesson including code, homework, blog, today before the review and knocked 2, 3 chapters of the code, this chapter for 2 summary, tomorrow to write the third chapter.

This chapter implements a simple game: Click a card on the table, flip the card, show its front or back, and display the number of clicks at the bottom of the screen. Throughout, following the concept of MVC, the model layer designed the table and card functions, the view layer adds UI resources and sets its properties, and the controller layer connects the interface elements of the view with the processing of the Controller through action and outlet. Here are some of the things that are designed.

Model

1. Parameter definitions in the method    -(void) Addcard: (Card *) Card Attop: (BOOL) attop; The initial exposure to this kind of writing is also very strange, because with C + + Java is different, adding "extra" attop, seems to be helpful in the semantic understanding of the Method 2. Alloc init: Unlike Malloc,new and so on can be used directly after the different, alloc after the init (or other INIT implementation) 3. Definition of subclass: Playingcard:card4. Type: Nsmutalearray,nsuinteger, and formatted string stringWithFormat [NSString stringwithformat:@ "%d%@", 1, @ "a"]5. Instancetype: The return type indicates that this object returns an object of the same type as itself after receiving the message, typically only  view1 in the Init method. Several inspector:file,attribute,size and so on 2. Project Insert Image resources: placed in images.xcassets (drag), and different screen devices to use a different resolution resources, where 1x version is a non-Retina screen, 2x version is 3 of the retina screen. Set the button's background picture  controller1 in attribute Inspector. All controllers are 2 inherited from Uiviewcontroller. Add the Action:control drag button to the controller's implementation file method definition for the UI element, and set the name, type, event type, and so on 3. UIImage type: Uses a UIImage type to represent the picture resource that was previously added to the project, and displays it: [UIImage imagenamed:@ "name"]4. Add outlet for UI elements: Same as action, control drag to the attribute definition of the implementation file, and set name, type, etc.   follow the steps of this course to achieve the desired effect, guess the most important mode of iOS development is MVC, From the logical layer to the interface layer is clear, the model layer contains the representation of data structures, databases, files and various data structures, the controller layer to add the individual UI elements of the action outlet to capture the operation of them, This modifies the model layer and feeds back to the view layer, while the view layer addsAdding a variety of UI elements, setting layouts, and even customizing UI elements and their animations, will be a testament to future learning.  

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.