Add a progressive sub-view instance for iPhone Programming

Source: Internet
Author: User

IPhone ProgrammingAdd a delivery Sub-AccountViewInstance learning is the content to be introduced in this article, mainly for systematic learning.Iphone ProgrammingSome details andViewFor more information, see this article.IPhone ProgrammingThe center adopts two important models:

Object-Oriented model

Model-View-controller (MVC) Design Mode

MVC division on iPhone:

View

Provided by the UIView class and its subclass and Its Related UIViewController class. PS: For Controller, a container is used to store instances of the UIView class and layout items on the screen.

Controller

Achieve through 3 key technologies: Delegation, target operations and notifications

Model 

The model method provides data by dragging the data source, meaning, and other protocols. The callback method triggered by the controller must be implemented.

Instance learning

In the example of P47 in the Pdf version, learn from the official website of Apple:

UIView class

Common attributes:

 
 
  1. Superview
  2. Subviews
  3. Window
  4. AutoresizingMask UIViewAutoresizing constant,
  5. Commonly used UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleRightMargin
  6. AutoresizesSubviews: indicates whether the subview automatically resets the size.
  7. Tag: tag of the View

Common Methods:

 
 
  1. AddSubview
  2. InsertSubview
  3. RemoveFromSuperview
  4. ViewWithTag

UIViewController class

Provides a basic view-management model for Apple applications.

UINavigationController and UITabBarController are subclasses of this class. They provide additional behavior operations to manage controllers and views of complex hierarchies.

Common attributes:

View:

The view managed by the current controller. It is the view currently visible to the Controller.

Common Methods:

LoadView:

Create a view for the controller.

WillRotateToInterfaceOrientation:

Used to notify the controller of screen flip to respond to corresponding changes

ShouldAutorotateToInterfaceOrientation:

Returns a Bool value to indicate whether the current view Controller supports the specified direction.

This function involves a constant, as follows:

UIInterfaceOrientation constant:

 
 
  1. typedef enum {  
  2.    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,  
  3.    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,  
  4.    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,  
  5.    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft 
  6. } UIInterfaceOrientation; 

Used to determine whether the screen horizontal and vertical la s are supported. For example, videos are generally horizontally watched. Therefore, the value can only be UIDeviceOrientationLandscapeRight UIDeviceOrientationLandscapeLeft. The complete code is as follows:

 
 
  1. // Allow the view to respond to 2 iPhone Orientation changes,like:  
  2. -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  
  3. {  
  4.     return (interfaceOrientation == UIDeviceOrientationLandscapeRight || interfaceOrientation == UIDeviceOrientationLandscapeLeft);  

Geometric structure:

CGRect

 
 
  1. A structure that contains the location and dimensions of a rectangle.  
  2.  
  3.     struct CGRect {  
  4.        CGPoint origin;  
  5.        CGSize size;  
  6.     };  
  7.     typedef struct CGRect CGRect; 

CGPoint

 
 
  1. A structure that contains a point in a two-dimensional coordinate system.  
  2.  
  3.     struct CGPoint {  
  4.        CGFloat x;  
  5.        CGFloat y;  
  6.     };  
  7.     typedef struct CGPoint CGPoint; 

CGSize

 
 
  1. A structure that contains width and height values.  
  2.  
  3.     struct CGSize {  
  4.        CGFloat width;  
  5.        CGFloat height;  
  6.     };  
  7.     typedef struct CGSize CGSize; 

CGFloat

 
 
  1. The basic type for all floating-point values.  
  2. typedef float CGFloat;// 32-bit  
  3. typedef double CGFloat;// 64-bit 

Summary:IPhone ProgrammingAdd a delivery Sub-AccountViewI hope this article will help you with the introduction of instance learning!

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.