My first App for iPhone is a simplified menu based in direct access which will be set with a default group of accesses and, they could be edited like user wants.
Followed this, some screenshorts of the App which is going to be available in Apple Store soon.
As we saw how we can define a UITableView, set its properties and personalize it, now we are going to learn how to navigate in our UITableView designed in the post which we talked about UITableView, which we customize with two rows and sections that depended by the contents of array.
At first we have to define the UINavigationController in one of our events: ApplicationDidFinishLaunching. We do it like that:
After this, we have to add a UIViewController to our project which will be personalized with a method of writing in a UILabel and change it with a UIButton like our 'HelloWorld' example.
We have to select the correct subclass for our code:
We continue adding variables and methods to the new class we have created. We define an UILabel, UIButton with their respective methods set them in files .h & .m
The appearance of our new View will be customized with a button and a label as we said.
By last, we have to add what happens when a row was select. We had two arrays, that's why I evaluate what section I select it.
After all, we obtain a simple application like this:
I started publishing posts by forgiving a feature of Objective-C really usefull for our application development allow us to generate automatically getters/setters. Also we usually have to think that our code have to be straightforward and it could be generalized. Properties are a kind of virtual member variables which offer us all we have said. This is what it look without use properties:
After we use properties in our code, it seems like this:
The word "retain"in parenthesis the setter function: it should retain the input value. Rest of the line specifies type and name of the property. After this, the class definition as follow:
We can use setter an getter methods which are generate by the @synthesize directive. This directive is used to instantiate the property Also we use the dot syntax to set or get a value as we used.
With this example, we see properties are so powerful feature to use in our software developer. Next post will explain the attributes that a property can be have.
Today we will see what is a UITableView, how define it and do a customization of them. UITableView is not more than a simple view of a list of information. We start defining a UITableView object in .h file of our proyect.
Later, to define it, mandatorily, we have to define methods that define basic properties of TableView, that in this case, will be the number of rows§ions that contain, and generate cells that contain the rows. The methods are:
We define the number of sections in UITableView, number of rows, and we access to cells's rows, initializing if necessary. Also, we add text to cell. With it we obtain a table, with two sections and two rows for each section with the word "prueba" that will be displayed.
After know basic operation of TableView, we can do a customization type basic and usefull of it.
We can define names of headers and footers of sections, define a determinate content for each section, with a array of objects (text, images, views, etc...). For it, we have modified the methods numberOfRowsInSection to give back the array content. We have create titleForHeaderInSection, that generate a title in fuction of the section and the method cellForRowAtIndexPath where the title for each cell will be the content of array depending of section. We haven't to forget add NSArray objects to .h file to our proyect. Finally, as it show in the video, we can see the result.