Small notes, tomb theft note novels
The system automatically releases an object when the object is created quickly. For example:
NSDictionary * dic = [NSDictionary dictionary]; // The System Automatically releases the memory once, and the object reference count is '-1'
Copy is used to create (copy) immutable objects;
MutableCopy is used to create (copy) mutable objects;
Frame: uses the parent control as the reference system. It sets the coordinates of the parent Control and Its width and height. The frame is fixed in its upper left corner;
Frame has a set method, which is specifically used to set it in the frame of all child controls in the method.
There is a struct in the frame:
1 CGRectGetHeight (self. view. frame); // get the height of 2 CGRectGetWidth (self. view. frame); // get the width of 3 CGRectGetMaxX (self. view. frame); // obtain the maximum X value 4 CGRectGetMaxY (self. view. frame); 5 CGRectGetMidX (self. view. frame); // obtain the intermediate X value 6 CGRectGetMidY (self. view. frame); 7 CGRectGetMinX (self. view. frame); // obtain the minimum X value 8 CGRectGetMinY (self. view. frame );
Bounds: it is based on its own reference system. The default coordinate is (0, 0), but it is mainly used to set the size of the control itself, with the Bounds (including width and height) of other controls) set the size of the reference object. It is generally used directly, and bounds is fixed with its own center point;
For example:
// [UIScreen (screen) mainScreen (main screen)]
1 self. window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen]. bounds]; // directly set your own bounds using the bounds (width and height) of the device screen;
Transform:
1 // define a Butoon 2 UIButton * button = [[UIButton alloc] init]; 3 // 4 // transform: a struct that contains: 5 // CGAffineTransformMake (width, positive number (clockwise rotation), negative number (clockwise rotation), high, X, Y) 6 Movement: 7 CGAffineTransformTranslate (button. transform,-50, 50); // a parameter item is added without 'make', which is to move and change 8 CGAffineTransformMakeTranslation (-50, 50); // The "Make" is based on moving back and forth between the original position and the changed value. 9 // when you need to move the position of a control back to the original position, you can assign 'cgaffinetransformidentity '10 buttons directly. transform = CGAffineTransformIdentity; 11 ZOOM: 12 CGAffineTransformScale (button. transform, 1.5, 1.5); // a parameter item is added without 'make'. 13 CGAffineTransformMakeScale (1.5, 1.5) is scaled based on the current 'transform ); // with "Make", it is based on the original size and the changed size value to switch back and forth 14 rotation: 15 CGAffineTransformRotate (button. transform, M_PI_4); // rotate for once every 4 points
MVC: M :( model) V: view (Interface) C: ViewController (Controller)
Each view has an attribute parameter 'subview', which is an array attribute that contains all the child controls contained in the view. You can query the number of child controls (subviews. count), or traverse all child controls.
A method sometimes used:
1 [self. view. subviews makeObjectsPerformSelector: @ selector (click)]; // traverses all the child control objects so that none of them can execute the subsequent methods.
1 [self. view. subviews enumerateObjectsUsingBlock: ^ (id obj, NSUInteger idx, BOOL * _ Nonnull stop) {2 // view is an array. Use the array Traversal method to traverse all the child controls in the view, obtain each object 'obj ', each object subscript 'idx', and stop the traversal condition 'stop' 3}];
The parent control view has a user interaction switch: 1 self. view. userInteractionEnabled = NO; // when disabled, all child controls will also disable user interaction.
1 [self. view bringSubviewToFront: buttom]; // The parent control takes the child control to the top of the current page for display
UIButton: You can call '. current ', whether you want to retrieve any attribute of the current button, such as slice, text, text color ..... can be used,
Example: 1 NSString * title = buttom. currentTitle; // retrieve the text of the current button