Simply put, Xib is a drag-control programming, or visual programming. With the IB and Xib files to organize the UI with respect to code, you can save a lot of code and time to get faster development speed. If you have ever been poisoned and maimed by the visual interface of the Microsoft home Visual Basic or other visual system , and therefore suspect interface Builder's pure pedigree and ability to work, it is recommended to take a look at these materials to correct the three views: Jean-marie Hullot's Interface builder myth as well as the green amid in a suit are used to build an application with IB at Next (FQ required). Alternatively, you might want to open the application folder on your Mac or the Apple Home app on your iphone. You will be surprised to find that IB is far more powerful than you can see: small tools such as the Calculator picker, up to iwork three-piece set, aperture or final cut for professional applications, none of which is done using IB for UI production.
In fact, IB and Xib are bundled in the Developer Toolkit from the first launch of the iOS SDK, and have been integrated directly into Xcode after Xcode 4 as part of the IDE. one of the main purposes of xib design is good MVC: In general, a single xib file corresponds to a viewcontroller, and for some custom view, it is often loaded using a single xib and loading from the main bundle. IB helps with the creation of view, layout, and relational mapping with file owner, among other things. For beginners, keep in mind that xib files are the content of the view, help to build a better concept of MVC, so that in the development of avoid or less detours.
Previously, IOS programming was two-part, one was Xcode, the other was Interface Builder. Later Xcode combined them together. A lot of people on Xib nib IB these three don't understand, only know xib, below I briefly introduce,
Xib refers to a suffix,
NIB is amid the main NS ERA,
IB is actually xib
Summing up, Xib Nib IB refers to the Xib drag control.
Let me explain in detail the use of Xib:
First, create a xib file
Then click Next and we have xib files in the project.
Then we need to initialize the controller and add it to the window's root view.
There are two parameters in this initialization,
Initwithnibname: This is Xib's name, we fill in the Xib project name prefix
Bundle: This is a bag, we can fill nil can also fill [nsbundle Mainbundle]
Bundle:nil ===== Bundle:[nsbundle Mainbundle]
Check API that this two parameters when all are nil, the system will
Find Text View.xib First
Find the text viewcontroller.xib again.
This time, we can go inside the xib,
We can see a row of small icons on the right. Let me introduce you.
From left to right
The first one, describes
The second one, find
A third, custom
Fourth, properties (first display their own properties, followed by the properties of the parent class)
Fifth one, frame
Sixth, establish an association.
Below, we drag the control to create a login page;
At this time, we will have three questions,
First, how do I add a response event to UIButton?
Second, how to add proxy to the control?
Third, how to define attributes, instance variables?
Let's take a look at the first question first,
First, how do I add a response event to UIButton?
We first click the mouse to UIButton, then press the CTRL key on the keyboard, and then drag to the. h file, as
Write a method name, and the method declaration, and the empty implementation of the method, will appear.
Here's a second question,
Second, how to add proxy to the control?
When we mouse click on the input box, then right mouse button
Then point to file ' s Owner.
This completes the Add agent: Then we write in the code to comply with such a proxy protocol, in hand-written implementation of proxy method is good.
One last question,
Third, how to define attributes, instance variables?
We first click on the control and then press CTRL, pointing to the point H file, as
And then named,
The results are as follows
The definition attribute is basically the same as above, as follows
The results are as follows:
Xib Nib IB Visual Programming detailed