How to get started with Xcode and Interface Builder

Source: Internet
Author: User

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:

 
 
  1. Keep your Xcode project open while editing your nib files.  
  2. Whenever you want to create a new class, or add an outlet or action to an existing class, do it in Xcode.  
  3. 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

 
 
  1. 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!

Related Article

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.