lunes, 11 de junio de 2012

Basics of Storyboard

If you have ever developed iOS applications you could notice that you used xib or nib to build the interface of your application.
Apple came with a new practical solution for this, remember that with xib you had to import each header of the view that you wanted to show.

Storyboard is a way to see the workflow of your application easily and use one file to manage all the user interface.

Lets see a little more about this:

When we create a new project we can choose if we want to use Storyboard or not, in this case we will mark this option

Then we can notice two new files with the ".storyboard" extension, we have one for iPhone and one for iPad because i've chosen Universal Device Family (both iPhone and iPad).

Once we click on the file we will notice like a grid when you have the sample views linked

 You have too on the right bottom corner the option to fit on screen or just zoom out/in. In this case if we will delete this view, we select both 3 and we can delete them.
Then we will go to our toolbar and add a new view controller to the workflow

If we see the properties of our view controller we'll notice a new useful property 'Is Initial View Controller' that determines which is the initial view controller to be launched when the application starts.

So now we will add some labels and we will match this ViewController inside the storyboard with our class.
We will create a new file->UIViewController subclass and we will name it InitialViewController  (We don't need to mark any checkbox for now).

So now we have our UIViewController subclass and we will go to the identity inspector and change our defined class UIViewController to InitialViewController that is the one that we've created recently.

Now we can run the application for iPhone and we will get something like this

No hay comentarios:

Publicar un comentario