DetailsXcodeAndInterface BuilderThis article describes how to work with them. The two most common methods for creating a UI for Apple IOS are:XcodeCooperationInterface BuilderFirst, directly useXcodeI believe most people will choose the former, and the latter should be "code control.
I. Introduction to Xcode and Interface Builder
When a project is created in Xcode, it is connected to Interface Builder by default and used to create the UI. The official introduction of Apple is as follows:
- Keep your Xcode project open while editing your nib files.
- Whenever you want to create a new class, or add an outlet or action to an existing class, do it in Xcode.
- To set the class of an object, simply type its name in the identity pane of the inspector window.
Officially said, create a class in Xcode and then join in IB. In practice, you may ask to what extent is the class created in Xcode ???
The answer is, you only need. define the object in the H file, and add the IBoutlet attribute. add attribute implementation to the m file. You do not need to use "alloc" to create an object. For example, if you use "alloc" to create an object, the value assigned to the object in the code will be invalid ); then assign values to the object in the Code. The compiled program will show that you want to assign values instead of the initial values in IB. Finally, the object is connected between Xcode and IB and the object attributes are modified in IB, it is intuitive and convenient. For action, add your method to the View Controller program, and then perform the join operation in IB.
OK. We define and load windows, view controllers, navigation controllers, and so on in the main agent program. In the View Controller program, we need to pay attention to the following, to load a view in the viewDidLoad method, loadView is the place where "code control" loads the view.
2. directly use Xcode to create the UI
As mentioned above, when creating a project in Xcode, it is connected to the Interface Builder by default. To avoid conflicts, you must cut off all connections with the Interface Builder when using Xcode to directly create the UI, the method is as follows:
1. Delete All *. xib files in Group & File, which are in the Resources folder by default );
2. Delete the "Main nib file base name" attribute in *-info. plist;
3. Set
- int retVal = UIApplicationMain(argc, argv, nil, nil);
Change
Int retVal = UIApplicationMain (argc, argv, nil, @ "your main proxy program name has no suffix )");
4. (optional) Delete the @ property and @ synthesize of IBoutlet, that is, its attributes and implementations.
3. This article only highlights several key points of attention when Xcode and Interface Builder are used in combination. For a comprehensive introduction, please refer to the official documentation and relevant reference books.
Summary: DetailsXcodeAndInterface BuilderI hope this article will help you!