iOS Development UIView Controls

Source: Internet
Author: User

1. Everything objects

2.LBS: Location-based services (HOT)

3. It's a good idea to check git when starting Xcode to create a project

4. Change the contents of a control such as Uilabel in the SB interface, the frame of the control will change with the size of the content, but changes in the property bar on the right will not affect the frame

5.IBACTION:SB interface originally called interface Builder abbreviation for IB,

6.m_pi_4 represents 45° and so on

OC Syntax rules: Direct modification of members of struct properties in an object is not allowed

  • ?
    1 2 3 4 5 6 7 8 // 1.先取出frame     CGRect tempFrame = _btn.frame;        // 2.修改y值   // 这个能修改是因为,这个tempframe只是一个简单的结构体,而不是对象的结构体,对象的结构体是不能直接修改,但是单纯的结构体是可以的      tempFrame.origin.y -= 50;          // 3.重新赋值按钮的frame    _btn.frame = tempFrame;

     

Important: Be aware of the type of arguments passed in by the method,

    • such as:-(ibaction) add: (ID) sender
    • Because the parameter passed in is an ID type, you cannot use dot syntax, such as Sender.tag.
    • Change (ID) to (UIButton *) to use dot syntax

Block blocks

    • Definition: You can pass parameters to a block just as you would pass a function. The block also has a return value. Unlike a function, a block is defined inside a function or method and is able to access any variable outside the block within a function or method scope.
    • Definition of blocks:
    • Int (^mysum) (int, int) = ^ (int a, int b) {
    • return a+b;
    • };
    • Defines a blocks object called MySum, which has two int parameters and returns an int. The right side of the equation is the concrete implementation of blocks
    • The block can access local variables, but cannot be modified.
    • Half of the format of method call block in OC:-(void) BTN: (void (^) ()) block
    • void----no return value
    • (^) Blocks of flags
    • () No Parameters

Two ways to exit the keyboard

    • Resignfirstresponder
    • When the control called the keyboard (the first responder) calls this method, it can exit the keyboard
    • Endediting
    • You can exit the keyboard as long as there is a first responder inside the control that calls this method

A general process for creating UI and implementing actions through code

    • 1. Setting up the UI interface
    • instantiating the control (specifying various properties for the control)
    • Add the instantiated control to view
    • 2. Dynamically changing the state of the program in the run according to the UI requirements
    • &NB SP;
    •  
    • 1. Define Properties
    • Define properties for controls that dynamically change the state of the program according to UI requirements, which is equivalent to creating Uioutlet steps in Storyboard
    • @property (nonatomic, Strong) UILabel *nolabel;
    • 2. Create a control for the property, add to the view
    • instantiate the control (specify various properties for the control)
    • Add the instantiated control to view
    • UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (0, +, +)];
    •     label.text = @ "1/5";
    •     label.textalignment = nstextalignmentcenter;
    •     [self.view Addsubview:label];
    • The
    • assigns a property to a control with properties:
    •     self.nolabel = label;
    • 3. Create an action when a key click is created (that is, create a method)
    • 4. Tap events for the monitor button
    • [rightbtn addtarget:self Action: @selector (RightClick) forcontrolevents:uicontroleventtouchupinside];
    •  
    •  

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.