Read the second chapter of the book today, mainly introduced the use of Xcode and some necessary instructions, and finally made a "Hello world!" Small program, is actually on the screen with a label display "Hello world!", a line of code is not written, drag and drop control, change the label font size color What, or relatively simple, the following to write this process, As for the use of Xcode is not here specifically described here, anyway, where to introduce where it.
1) Start Xcode
Select "Create a new Xcode project", and the project is created.
2) template selection, select "Single View Application" template
Single view application application, Xcode creates a primary master by default (you can simply think of it as a panel in Visual Studio, a container), and then all the other elements are placed on top of the master, the whole " Hello world! " There is only one label, and all you have to do is choose this template.
3) Fill in the name of the project you want to create: Hello World
Product name fills in "Hello World", and company identifier is an identifier that indicates which corporation the program belongs to (I think so, I can write anything, I like it, but it seems that this does not fill is OK, Anyway, it's just a matter of learning), the rest is the default state, select "Next".
4) Select the location where project is saved and complete the creation
I simply saved project to the desktop and finally clicked the "Create" button, so a simple project was built.
The feeling is pretty simple, and the steps are similar to creating a project in Visual Studio.
After creating the project, Xcode displays the following, feeling the interface is quite strange, many things are first seen, can be recognized at a glance is the leftmost item navigation bar (Project Navigator, a bit like visual The solution window in studio) and the lower-right corner of the control library (Object library, similar to tools in Visual Studio), other things need a little bit of groping to get acquainted.
5) Add a Label control
First select the "bidviewcontroller.xib" File in Project Navigator (the full name of Xib is Xcode ' s Interface BUilder, Designed to manage and interact with the user interface), after selecting, Xcode becomes the following, an iphone interface appears, and then a control is dragged onto it.
Then in the control bar (Object Library) to find the label control, to the interface to drag, put in any position you like, I was left and right play in place (there will be auxiliary lines appear, help you to put). These operations are very familiar with not much difference in vs.
Change the label display text, double-click the label directly with the mouse, and then the text in the label will be selected, the text will be changed to "Hello World" on the line. The operation here is a little different from VS, and in VS, if you double-click a control, it is likely that a mouse click event is added to the control, whereas in Xcode it is only the text of the control that changes its display. After the change, the position of the control is adjusted to the left and right of the play, the interface is as follows.
If you want to change the label font, color, etc., check the label, the right side of Xcode will appear in the label's property bar, directly in the properties of the change can be, and very simple, such operations and VS is similar.
6) Compile and run
Well, to this location, all the operation should be said to have been completed, the final step is to compile the run, the mouse click on the upper left corner of the "Run" button (shortcut: Command + r,build shortcut: Command + B), compile and run.
An iphone simulator will show up and then just the Hello World shows up on the iphone, such as.
At this point, the first iphone program has been completed, very simple, a line of code has not been written.
7) Replace program icon
There is a slight flaw in the above Hello World, when you click on the emulator's home button to return to the desktop, you will find the icon of Hello World is gray (the iphone default icon for programs without icons), see
The reason for this is very simple, we do not set its icon, to add the icon, back to Xcode, select the left Project Navigator in the program root node (the top, the blue icon of the node)
When selected, the "APP Icons" column appears in the middle of Xcode with 2 icons, one for normal resolution (for iphone with a non-retina screen, 3GS or earlier iphone) and the other for high resolution (for retina screens, Iphone4 and later models)
Only the general resolution of the picture at hand, can only choose to add the left side of the picture, the mouse right click on the left icon, select "Select File", select a picture.
Then recompile run the program, and so on, after the program in the iphone simulator display, click the Home button back to the desktop, at this time, Hello World already has a own icon, this process is also very simple.
Summarize:
In addition to introducing some of the usage and layout of Xcode, the second chapter is about how to create the first iphone app, and the process is simple, so that you can feel that creating an iphone program is not as difficult as it might seem, and that you are interested in developing the iphone.
Well, this is the study record here, the next chapter will learn to add buttons for the app, the iphone app design mode (Mvc:model-view-controller), relative to this chapter, the content will be more substantial, the difficulty will be increased.
Thank you!
Hello_world.zip