Reputation: 976
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?
Upvotes: 0
Views: 1771
Reputation: 194
You add it in the tableView:cellForRowAtIndexPath method in the UITableViewDataSource protocol. See the example here: http://iosdevelopertips.com/user-interface/creating-unique-looking-tables-with-custom-cells.html
Upvotes: 1
Reputation: 6642
Yes, as jeremie stated you need to add the some UITableViewDelegate and UITableViewDataSource methods to get a UITableView fully functional.
Upvotes: 0