iphone development "One" starting from HelloWorld

Source: Internet
Author: User

Reprint please indicate the source. Original URL: http://blog.csdn.net/m_changgong/article/details/8013553 Zhang Yanquang

Start with the classic HelloWorld and enter the iphone development portal!

Keyword: HelloWorld IPhone IOS

1. Open Xcode and select "Create a New Xcode project"


2, the project in Xcode is divided into two categories, one is iOS, the other is Mac OS X, the former is Iphone/ipad development, the latter is for Mac PC development.

Select "Application" in the iOS category and select the "Single View Application" project template (each template feature below is explained below)

Xcodeproject Template Description:

Master-detail Application:
iphone device: The corresponding xcode4.0 navigation-based application, based on the navigation mode of the project template.
ipad Device: Splite view-based application of the corresponding xcode4.0, project template based on cut mode.


OpenGL Game: The corresponding xcode4.0 OpenGL ES application.
Single view application: The view-based application of the corresponding xcode4.0, based on the project template for the individual views.
Tabbed application: The corresponding xcode4.0 tab Bar application. The project template based on the tab bar.
Utility Application: Utility application of the corresponding xcode4.0. It's very seldom used, and it's not working at the moment.
Empty application: Create a blank project with the window-based application of the corresponding xcode4.0.

3. Product Name: The name of the products (iphone app) produced by project


Company Identifier:com.zyg.ios, for application package name

Bundle Identifier:company identifier+product Name

The class name generated by class Prefix:project is added with the prefix that is filled in here

Device Family:project the appropriate equipment type. iphone or ipad (the development of these two devices is different, the later article will talk about)


Use storyboards: Do not select the storyboard, the following article will be dedicated to the storyboard

Use Automatic Reference counting: Own active reference count. When selected, the memory release work does not need to be handled by itself. Do not select. When learning the iphone development, be sure to learn to control the release of memory, when real development can select the item.

Include unit Tests: whether the unit test is included. Do not select, the following article specifically explains this.

4. Select the folder Iosdev, save the project

5. Expand Helloworldproject


HelloWorld: This folder is a logical folder. This folder does not exist in the file system.

It is a group in the Xcodeproject. The basic development is to create sub group or file under the group.
HelloWorldAppDelegate.h: proxy class header file
HELLOWORLDAPPDELEGATE.M: proxy class source file
HelloWorldViewController.h: View Controller class header file
HELLOWORLDVIEWCONTROLLER.M: View Controller class source file
Helloworldviewcontroller.xib: Includes user interface-related components
supporing files: The ability to store source files, is generally the storage of resource files.
Helloworld-info.plist: A list of properties that includes project information.


Infoplist.strings: Application internationalization, including multi-lingual translation.
MAIN.M: Including iphone application entry function Main, this file does not need us to do whatever changes.
HELLOWORLD-PREFIX.PCH: Includes a list of some header files.

Xcode will precompile these header files, assuming that you need a large number of global variables in project. You can also define macro variables as global variables in this file.
Frameworks: Introduced system framework, introduced by default
UIKit.framework:ios UI Component Class Library
Foundation.framework:ios Base Class Library
Coregraphics.framework:2d Drawing Class Library
Products: Includes product compiled after project Helloworld.app

6, through the face of the folder structure of the explanation we know that Helloworldviewcontroller.xib is to store user interface related components. Click to open the file and locate the label component in the lower right corner of Xcode (you can enter a label in the search box to locate the component at high speed). Drag the component to a blank view, and the drag process will appear horizontally, vertically to the Zillen line, so that the label is horizontally and vertically centered with the label. Then double-click on the lable. Enter "Hello World".


7, hold Command (CMD) +b compile project, and then Cmd+r. Perform project, such as the following

Summarize:

1. Where is the entrance to the program? Start the process?

1) in the main function in MAIN.M, the function calls the Uiapplicationmain. And the last parameter was used for helloworldappdelegate, and we pushed the Uiapplicationmain function to start the Helloworldappdelegate class.

2) The View controller Helloworldviewcontroller is also initialized in the Didfinishlaunchingwithoptions method in HELLOWORLDAPPDELEGATE.M. The initialization parameter uses the @ "Helloworldviewcontroller", which is actually helloworldviewcontroller.xib.

3) Helloworldviewcontroller.xib includes a user interface component, so the UI component is displayed on the view after the Helloworldviewcontroller initialization is complete. Our Hello world shows up on the simulator screen.

The program starts the process with the above concept can be, with the subsequent learning will gradually deepened. More clearly.


2, the label component can be dragged onto the view display, no matter what other complex components theoretically can do so. So that it shows up.

3, Helloworldviewcontroller is called the View controller, then the control operation should be implemented in this class.

How do you interact with labels, control the display of labels, content, and so on? Take a look at the next article ...


Download the source of this article

iphone development "One" starting from HelloWorld

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.