Developing on iPhone (4): our first application (II)
Author: jack // Category: IPhone Application Development
In our previous post explained how it was going to be our HelloWorld application and the steps we would take to build our application, in addition to providing links to documentation required. In this article we started opening the XCode and began to develop.
Step 1. Create the Project.
That is why we opened and closed XCode (if you leave), the welcome screen of the application. Before creating our project, we can go into the preferences of XCode. In General -> Layout choose 'All-In-One', at least if you will be able to compare what you see on your screens with images you will see.
At this time we created the project: File -> New Project, and choose View-Based:
Step 1. Create the Project.
That is why we opened and closed XCode (if you leave), the welcome screen of the application. Before creating our project, we can go into the preferences of XCode. In General -> Layout choose 'All-In-One', at least if you will be able to compare what you see on your screens with images you will see.
At this time we created the project: File -> New Project, and choose View-Based:
As we indicated in the previous article, for a project View-Based XCode we created a hearing linked to a class Controller (remember that we spoke of the MVC pattern). Calls to the project and guardadlo HelloWorld in the folder you want. You will see something like this:
We see that we have several files:
HelloWorldViewController.hy HelloWorldViewController.m. Both correspond to the driver of our screen. Here is the logic related to our view, in our case, this should be the code that makes the value of the label change with the introduction in the box. We see a file. H and another. M. The first is the header, in Java would be the interface. Here are the declarations of variables, methods, etc. The file. M is the one that already contains the deployment.
HelloWorldViewController.xib. ib = Interface Builder. This file is our view, the screen. MainWindow.xib is invoked by the main front of a view that does not touch.
HelloWorldAppDelegate (. H and. M). Not going to change, you have a pointer to our ViewController.
Info.plist. It is an XML with information about our application. Here we can show by example what is the icon of our application.
Step 2. To design the interface.
Let's start to "draw" the screen of our application. To do so, in XCode we double-click on the HelloWorldViewController.xib, and we will see that opens the application Interface Builder. First, just as practical advice I strongly recommend that you have always verifiquéis open pallets and Inspector Library. You can open the Tools menu in Interface Builder. The Library palette allows you to add different controls to your eye, and the Inspector palette lets you view the properties of each object and modify them.
We are not going to try to make an application pretty, but it works. Begin by locating the screen, labeled View. If you're not open, you open it by double-clicking on View in the next screen:
HelloWorldViewController.hy HelloWorldViewController.m. Both correspond to the driver of our screen. Here is the logic related to our view, in our case, this should be the code that makes the value of the label change with the introduction in the box. We see a file. H and another. M. The first is the header, in Java would be the interface. Here are the declarations of variables, methods, etc. The file. M is the one that already contains the deployment.
HelloWorldViewController.xib. ib = Interface Builder. This file is our view, the screen. MainWindow.xib is invoked by the main front of a view that does not touch.
HelloWorldAppDelegate (. H and. M). Not going to change, you have a pointer to our ViewController.
Info.plist. It is an XML with information about our application. Here we can show by example what is the icon of our application.
Step 2. To design the interface.
Let's start to "draw" the screen of our application. To do so, in XCode we double-click on the HelloWorldViewController.xib, and we will see that opens the application Interface Builder. First, just as practical advice I strongly recommend that you have always verifiquéis open pallets and Inspector Library. You can open the Tools menu in Interface Builder. The Library palette allows you to add different controls to your eye, and the Inspector palette lets you view the properties of each object and modify them.
We are not going to try to make an application pretty, but it works. Begin by locating the screen, labeled View. If you're not open, you open it by double-clicking on View in the next screen:
On the hearing, brought forward from the Library palette up a TextField, a label underneath and finally a Round Rect Button. We look, if we have selected a control such as TextField, we can move the size of this control, relocate on screen ... and the Inspector palette, we can dispose of their properties. Selecting the button we can put a value Title "Change!". In the end we will be something like this:
With this we have defined the interface of our application. Complies with what we had expected: a text box (hereinafter TextField) where they get information. A Label (fixed text) and a button. When we push the button, the Label show what they've written in the TextField. To do this we must create the variables that referenced the Label and TextField in our ViewController and we will tell Interface Builder relationship between the Label and TextField with these variables. There will also be to create a method in the ViewController to be responsible for updating the value of the label with which we have entered into the TextField, and relate the button with this method in Interface Builder. All this will be steps 3, 4 and 5 of our original script, and will be explained in the next post.
However, before the end I strongly recommend that you fijéis in what emerges in the Library palette when you have selected such a TextField to add it to the hearing:
However, before the end I strongly recommend that you fijéis in what emerges in the Library palette when you have selected such a TextField to add it to the hearing:
Please note that explains that the TextField control, but also put under "UITextField." This is important because we are signaling what kind of framework UIKit Cocoa corresponds to this control. This gives us a clue: in order to create a variable that handles this control in the ViewController, you'll have to be kind of UITextField.
0 Responses to "Developing on iPhone (4): our first application (II)"
Post a Comment