IOS UI basics 01 and iosui01

Source: Internet
Author: User

IOS UI basics 01 and iosui01

  • Controller

    • 1. What is a controller? Any class inherited from UIViewController is called a controller.
    • 2. Role of the Controller: Manage the UI interface (responsible for managing the creation of the UI interface and handling of some events)
  • IBAction

    • Connection Mode
      • 1. Connect from "controller" to "Storyboard"
      • 2. Connect from "Storyboard" to "controller"
      • 3. connect directly to the top of the "Storyboard" Interface
      • 4. Connect the toolbar directly to the Storyboard in "Storyboard ".
      • 5. You do not need to define a method to connect directly from "Storyboard" to "controller ".
    • Notes for connecting IBAction lines
      • 1. Notes When copying elements in Storyboard
      • 2. The previous connections will be copied together during the copy operation.
      • 3. One method can associate multiple controls
      • 4. A control can be connected to many methods in development. Generally, it is not written in this way.
      • 5. If you delete the method associated with the button, a classic error reason: '-[ViewController redBtnClick]: unrecognized selector sent to instance 0x7fb4aa618e50' will be reported after the operation'
      • 6. IBAction can only be returned as a method. IBAction = viod
  • UI widget size

    • Most UI controls do not have the default size, so UIButton is invisible.
    • Frame
      • Frame is 0, 0 in the upper left corner of the parent control.
      • UIButton *btn = [[UIButton alloc] init];btn.frame = CGRectMake(100, 100, 100, 100);
    • Bounds
      • Bounds is set to 00 in the upper left corner. Therefore, setting the bounds x/y is invalid. Generally, you can use bounds to modify the bounds size.
      • UIButton *btn = [[UIButton alloc] init];btn.bounds = CGRectMake(0, 0, 100, 100);
    • Center
      • The center is the point of intersection of the control width and height, half of the width and height.
      • Generally, the center is used to modify the location.
      • UIButton *btn = [[UIButton alloc] init];btn.center = CGPointMake(200, 200);
  • ViewWithTag
    • ViewWithTag can only find the current control and the Child control of the current control. It cannot find the sibling control or the parent control.
    • Search order: 1. First find yourself 2. Find child Control 3. Find indirect child control (Sun Tzu ..)
    • Obtain the value of the corresponding tag using the tag
  • Anonymous Classification
    • Differences between anonymous and Classification
      • 1. The anonymous category has no name, and the category has a name.
      • 2. The implementation of anonymous classification is not required, but the implementation of classification is required.
      • 3. for anonymous classification, you can declare attributes or methods. For classification, you can only declare methods.
    • Notes
      • Attributes and methods that are being developed but do not need to be exposed to the outside world will be uninstalled from the anonymous category.
      • We recommend that you write attributes in anonymous categories (extension/class extension)

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.