views:

73

answers:

2

Hi, please I need some advice about design approaches in iPhone programming. I want to display a table view (with three cells that will never change) and a UIDatePicker. I don't use Interface Builder.

I created a UIViewController subclass and tried to put all together in its viewDidLoad method:

UITableView *myView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 250) style:UITableViewStyleGrouped];
[self.view addSubview:myView];

datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 250, 320, 216)];`

and other initialization params...

[self.view addSubview:datePicker];

I miss something, I don't understand how to add UITableViewCell objects to myView?

I'm all wrong?

A: 

You add it in the tableView:cellForRowAtIndexPath method in the UITableViewDataSource protocol. See the example here: http://iphonedevelopertips.com/user-interface/creating-unique-looking-tables-with-custom-cells.html

Jeremie Weldin
A: 

Yes, as jeremie stated you need to add the some UITableViewDelegate and UITableViewDataSource methods to get a UITableView fully functional.

raidfive