Monday, September 12, 2011

Do you know Objective-c? UITableView

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&sections 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.




No comments: