views:

628

answers:

2

Greetings,

Problem:

I have a main view, that already is associated with a xib file, an appdelegate class, and a controller class.

Now, opening its xib file in interface builder, I add a UITableView.

Then, in its controller class, I create the IBoutlet code to use it, let's say: tableView.


Questions:

1) Where do I go from here in order to populate that table, and then to implement methods to handle events?

2) What is the best way to create/implement a UITableView and then add it to a parent View?

Thank You very much. Yohann T.

ps: I have looked at a couple tutorials, none showing how to hook it to a parent view.

+2  A: 

1) Where do I go from here in order to populate that table, and then to implement methods to handle events?

A UITableView gets its data from a UITableViewDataSource, and it lets a UITableViewDelegate handle events associated with in. Normally, your controller class will implement both of those protocols, i.e.:

@interface MyViewController :
    UIViewController <UITableViewDelegate, UITableViewDataSource>

Then, in Interface Builder, you can make the association from the controller class to the dataSource and delegate properties of the UITableView object.

2) What is the best way to create/implement a UITableView and then add it to a parent View?

The easiest way is with Interface Builder; drag-and-drop the UITableView right into your parent view.

Shaggy Frog
A: 

This is actually a question similar to this situation.

I have built the interface where i draged a UITableView into the UIView and connected my class to become the UITableViewDelegate and UITableViewDataSource of this UITableView.

The issue is that all works fine when I click on the table i get it to open a modal of another view i've prepared, but when that modal closed i get back to the UIView containing my UITableView so when clicking on the table again the app crashes. I suspect that table doesnt know its delegate any more or something like that, but i couldnt figure it out yet.

Please help me fix this. I also posted a question here

Cocoa student