Search code examples
xcodeuiviewcelltableviewuitableview

How to manage UI Table View in View Controller


I've got a simple UI View, with some items in it. I'd like to place in it a Table View.

Can anybody explain me with easy steps what do I have to write in order to manage it?

I have another UITableView with elements in it, rows etc. The problem is implementing a TableView in a UI View: I don't know how to add rows etc from there.

I tried, with no success, to do the following:

@interface SecondViewController : UIViewController <UITableViewDelegate> {
UITextField     *indirizzo;
NSMutableData   *data;
UIButton *compra;

and then Implementing, in the .m file, the specific methods like

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 10;
}

But the table doesn't change.


Solution

  • Well for start if you want to add rows to a UITableView you need to declare your UIViewController as the tableView DataSource not delegate. (delegate is for other stuff)

    You should go over the Table View Programming Guide