Stanford IOS Learn Notes-2

Source: Internet
Author: User

The previous article concludes that the first six sections of the Stanford video need to be summarized in three main parts:

    1. Summarize the professor's introduction to iOS
    2. Summarize the grammar that the Professor speaks in these six lessons.
    3. Mvc,cocoa Touch, Happiness Demo

The first two parts in the previous article probably comb a bit, at that time some of the details of the knowledge point is not summarized, after all, if you really want to summarize, each knowledge point can be expanded into an article. Today this article focuses on combing the third part: Mvc,cocoa touch,happiness Demo.

1. Mvcdivide objects in your program into 3 "camps". Model:what you application are (but isn't how it's displayed) (Totally UI Independent) Controller:how your model is Presente D to the user (UI Logic) (specific to each APP) View:your Controller's minions (always generic shared by Apps)  the MV C is all about managing communication between camps. Controllers can always talk directly to their model.controllers can also talk directly to their View. (Outlet, if we have the property of View in Controller, it marked as outlet) The Model and View should never speak to all other. Can the View speak to its Controller? Yes, but since the View was always generic, it should talk-to-Controller in the blind, i.e. based on the knowledge It doesn ' t know much about Controller. Also, it should talk-to-Controller in a structured-in-the-go. Class Professor introduces three examples: Target+action,delegate,data source (view cannot contain data, data from Co Ntroller, rather than from the model). On the whole, these three are an application of the proxy mode, and the controller takes himself as the agent of the view. This proxy method is typically defined as a delegate Protocol, and thenThe view contains a handle with this protocol. The Controller implements this Protocol and assigns itself to the handle inside the view. The standard proxy mode. It looks like you're going to have to review the design pattern later. 2. Cocoa Touch

The title may not be right, I do not know the scope of the discussion is not belong to Cocoa Touch, and so I see a few more sections, should know it ...

This section is mainly about the concept of view, and the concept of gestures. Intuitively, I think these two parts should also be the most important part of View/ui. Probably comb these concepts, listed below, easy to review it later.

  1. View
    1. View is a rectangular interface.
    2. View is hierarchical (hierarchical). A view can have Superview, (only one can be easily understood if one is available). Can have a lot of subview
    3. The order of the subview of a view is important, and the view behind the array is displayed in front of it.
    4. The top of the (useable) view hierarchy is the controller ' s Var view:uiview
    5. Initializing a UIView:
      1. Try to avoid initialiser if possible
      2. A UIView ' s intializer is different if it comes out of a storyboard:init (Frame:cgrect), init (Coder:nscoder)
      3. If you need a initializer, you need to implement them both.
  2. Coordinate System Data Structure:
    1. Cgfloat/cgpoint/cgsize/cgrect, remember not to use float/double these, or the mutation will hang.
  3. View coordinate system (coordinate systems for views):
    1. Origin is upper left
    2. Figure out points and pixels. Pixels is the minimum-sized unit of drawing your device is capable of. Points is the units in the coordinate system. A point may be one or 2 pixels. The design is point-based.
    3. Several important properties of UIView:
      1. Bounds:cgrect//A view ' s internal drawing space ' s origin and size
      2. Center:cgpoint//The centre of a UIView in its Superview ' s coordinate system
      3. Frame:cgrect//The rect containing a UIView in its Superview ' s coordinate system
      4. Notice the difference between bound and frame
    4. Typically, you create a view through storyboard, or you can create it from code, but less.
  4. What if I draw a drawrect?
    1. You can use the C type API (Core Graphics)
    2. Or you can use the Uibezierpath Class. (this time should be turned over the document, this is not written here)
    3. Uicolor
    4. UILabel
    5. Nsattributedstring
    6. Attributed String
    7. Uiimageview
    8. Uiviewcontentmode (Redraw)
  5. Gestures
    1. Uigesturerecognizer
    2. The ways to using a gesture recognizer:
      1. Adding a gesture recognizer to a UIView (asking the UIView to "reconize" that gesture), done by the Controller.
      2. Providing a method to "handle" that gesture (not necessarily handled by the UIView). Done either by the controller or by the controller.
    3. Uipangesturerecognizer
    4. Uipinchgesturerecognizer
    5. Uirotationgesturerecognizer
    6. Uiswipegesturerecognizer
    7. UITapGestureRecognizer
3. Happiness Demo

The professor made a happiness demo in sections fifth and sixth, mainly demonstrating the use of the above concepts. Demo followed a bit, but still do not know very well, wait for yourself to read the code a few times, and then to summarize it.

Stanford IOS Learn Notes-2

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.