Jiugongge's computing ideas and jiugongge's computing ideas

Source: Internet
Author: User

Jiugongge's computing ideas and jiugongge's computing ideas

(Slice may not be displayed in IE browser)

Note the following tips before taking a note:

Common Properties and methods of UIView:

1. @ property (nonatomic, radonly) UIView * superview;

Get your parent control object

2. @ property (nonatomic, radonly, copy) NSArray * subviews;

Obtain the objects of all its child controls (the order of array elements determines the hierarchical display order of the child controls-the larger the subscript, the more displayed it is)

3.-(void) addSubview :( UIView *) view;

Add a child control view

4.-(void) removeFromSuperView;

Remove from parent Control

5.-(UIView *) viewWithTag :( NSInteger) tag;

Find the corresponding control based on a tag ID (generally child Control)

6. @ property (nonatomic) CGRect frame;

Position and size of the control frame in the parent control (the coordinate origin is in the upper left corner of the parent Control)

7. @ property (nonatomic) CGRect bounds;

The position and size of the rectangle frame of the control (the coordinate origin is in the upper left corner of the control, so the x and y of bounds are generally 0)

8. @ property (nonatomic) CGRect center;

Point position of the control (with the upper left corner of the parent control as the coordinate origin)

Next, let's take a note of today:

  • Use the index of the control to calculate the row number and column number of the control.
  • Use the column number to calculate the x value of the control
  • Use the row number to calculate the y value of the control

Small details, broken knowledge:

  • When multiple controls are added, the index of the control is the length of the array where the control is located.
  • The number of columns in a control is the index number of the control to take the remainder of the total number of columns; the number of rows is the index number of the control to take the modulo

Code example (this code is taken from the entire code segment. The function of the entire code segment is: Click the Add button to add products to the Panel. The total number of items is two rows and three columns ):

  

Note: shopViewW and shopViewH are pre-defined definite numbers. shopX and shopY are calculated later.

2. each time you click a button, a product is added to the next position. The width x2 of each product is fixed. Therefore, to calculate the x value of the next product, calculate the x3 value first,

In this way, the x value of the number of squares is several times (x2 + x3.

Note: shopsView is the parent control that defines shopView, which is equivalent to the white background panel behind the square.

At this point, all the computing ideas and methods of jiugongge are over.

 

Additional knowledge (shopsView is the parent control below ):

1. Remove the control that exceeds the boundaries of the parent control: self. shopsView. clipsToBounds = YES;

2. Get the last data in the array: [shopsView. subViews lastObject]

3. Delete the last view in the parent control: [[shopsView. subViews lastObject] removeFromSuperview];

4. HUD:

AKA: Indicator/mask

Used to indicate what happened to the user. For example, the message "Network instability" appears on the mobile phone.

Summary of scheduled tasks:

1. performSelector

[Self defined mselector :( nonnull SEL) withObject :( nullable id) afterDelay :( NSTimeInterval)];

The first parameter refers to the method packaging. When used, @ selector (method name) is passed)

The second parameter is passed to the parameter in the called method. If the method does not have a parameter, It is nil.

The third parameter is set to second, which is a double value.

2. GUD

Dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t) (delayInSeconds * NSEC_PER_SEC), dispatch_get_main_queue (), ^ {

Code to be executed after a specified delay

});

Here, you only need to fill in two places, that is, the number of seconds at 'delayinseconds ', and the code in {}, that is, the code in 'delayinseconds' will be executed in {} seconds.

3. NSTimer

[NSTimer scheduledTimerWithTimeInterval :( NSTimeInterval) target :( nonnull id) selector :( nonnull SEL) userInfo :( nullable id) repeats :( BOOL)];

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.