IOS adds xib to UIView

Source: Internet
Author: User

A period of time did not knock the code, some of the previous simple will not do, rummaging and trouble, so it is recorded.

1. Open the project and create a new class AAA that inherits from UIView;

2, create a blank xib, the same name AAA

3. Associate Xib with UIView, click File's Owner, class to select AAA view.

---》

4, pull a view on the Xib, set the background bit red, call this uiview on the controller, test the effect, the normal display after running.

// Call the Xib view,    AAA *av =[[[nsbundle mainbundle]loadnibnamed:@ "aaa"  owner:self Options:nil] Lastobject];     // Set Size    Av.frame = CGRectMake (+);     // Add a View    [Self.view Addsubview:av];

Two: Pull TableView on the Xib view. and set the proxy, agent settings, it should be noted that the implementation of the proxy method is in the controller, not in the UIView

The table is displayed normally after running, but if the controller is added to the navigation bar, the table header will be empty.

IOS adds xib to UIView

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.