IOS loads a custom view from Xib

Source: Internet
Author: User

Think that the first major in the school is. NET, came to the company, immediately into Java development, and then jump to the development of iOS, it is really good ~ ~ Days of accidents, clouds and unpredictable hey, nonsense over,let ' s go~

Newly developed iOS development, has been thinking of a problem, IB can be a graphical design interface, for the hair is not directly to the design of the interface directly reuse it? Baidu a lot, found that most are dependent on the controller to achieve, to set the file Owner, sister's, the elder brother just want to reuse a simple view good, to your sister's controller ah, so then search, the result is no God horse big results, mainly his lazy hands to practice, Today decided to try it yourself, the results can still be returned.

Customize a Xib view,

Then in the place where you want to load the code, I use the swift,oc myself looking at the same

Self.title = "Test"        = Nsbundle.mainbundle (). loadnibnamed ("Wsuitableviewforloaddata", Owner:self, Options:nil)        = objects.last as wsuitableviewforloaddata        = "What's the situation        Here" = CGRect (x:0, Y:64, Width:self.view.bounds.width, height:self.view.bounds.height)        self.view.addSubview (view)

Command + R, Direct:

Over, you crossing, the text in lb successfully changed, then you can reuse it ~ ~ ~

IOS loads a custom view from Xib

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.