1. Background
Some of us can not just use code to build the interface, the code is omnipotent, you can implement the interface in other ways, with the code will certainly be able to
Implementation, but we do not need to do so, sometimes with xib will be a better choice, code and xib the pros and cons of the place we need to know, in order to
Taking into account the advantages of these two building interfaces, mixed use is a good choice. (I'm having this problem writing a static form in code.)
, I will not do this, so the implementation is also dynamic, I think it is not possible to achieve static, in this way to achieve the form to obtain data will be
A big problem: with the agent can be achieved, really in this way to do you will feel very troublesome, xib static table also has great convenience, because
For each control that can be accessed directly. )
2. Development environment
My development environment is Xcode 5.1.1,ios SDK 7.1
3. Two implementations
First, build the class file, and then build Xib
Sometimes there are problems in this way, so it's not recommended.
Steps:
1. Create a new class file
2. Create a new Xib file, preferably the same as the class file name
3. Two File Creation Association (note the place where the mark was marked)
1) Drag a view to the top. (The view cannot be Viewcontrol, this is the key Viewcontrol it is not done)
2) Association class file
3) Associated View. (Hold down CTRL and drag the dots next to the screen so that the associated lines are established)
4. Using Xib (reference header file), new
Firstviewcontroller *firstview = [[Firstviewcontroller alloc]initwithnibname:@ "First" bundle : nil];
Second, the construction of the file when the time to tick the new xib
Use directly after the new build.
4. Source code Download
SOURCE download
IOS uses code +xib to build UI interface instances