views:

103

answers:

1

Hello,

I'm very new to iPhone programming, and I'm currently following tutos to understand the whole thing. I've been able to do what I needed (retrive data from a JSON http server, parse them with YAJL and plot the data in core plot). I have done this in a "simple" view where I have added a UILayerHostingView as requested by core-plot.

I am now trying to follow this tuto: http://blogs.remobjects.com/blogs/mh/2010/01/26/p973 but I am missing the first part regarding the views...

My understanding is that I need to create a view with a UITableView first. Then add a UITableCellView to make the first cell be able to contain the graph ? Is this right ? Where does the method "(id)initWithStyle:(UITableViewCellStyle)style" come from ? For my needs, only the first cell needs to contain a graph, I will put some other info in the other cells.

As for now, I have created a new GraphListViewController, in the corresponding view I have added a listview but I do not see any auto generated methods regading cell customisation ? Do I need to implements DataSource in this controller and manually add some customisation methods ? Do I need to add a UITagbleViewCell to this UITableViewTable within IB ?

Hope I am not getting to confusing...

Thanks a lot for your help, Best Regards, Luc

+1  A: 

Hi Luc,

To start with, create a new file ...

Cocoa Touch Class -> UIViewController subclass

and click the UITableViewController subclass checkbox. This will do all the tableview work for you. You can now open the xib file and change all the properties that you want for this.

Once this is done you need to populate the cells within the table. The first thing you need to do is to tell the controller how many cells to display. For this update the numberOfRowsInSection: method to return how many you want.

The next part is where you want to create the cell and is done mainly in the cellForRowAtIndexPath and for this I'm gonna redirect you to the following good tutorial on adding custom cells.

http://iphonedevelopment.blogspot.com/2009/09/table-view-cells-in-interface-builder.html

This explains a bit of the 'magic' that happens

Hope this helps

Liam

Liam
Thanks Liam. I missed all this magic as I manually specified to inherit from UITableViewController then I did not have the additional autogenerated methods. I did what you said, and then created the 3 files at once (.h, .m and .xib). In this case, I do not have to handle manually a tableView outlet, right ? This is all linked automatically ? Thanks for your help. Luc
Luc
Just a thing, doing so I do not get the auto generated "- (id)initWithStyle:(UITableViewCellStyle)style " method. Is this normal ?Thanks a lot, Liuc
Luc
That's ok, you can set the style within the xib file, it makes it a bit easier. Regarding the the tableview outlet, correct, you do not have to handle it manually.
Liam
Thanks a lot Liam, that helped me a lot.Cheers,Luc
Luc