How can I programmatically add more than just one view object to my view controller?
- by BeachRunnerJoe
I'm diving into iPhone OS development and I'm trying to understand how I can add multiple view objects to the "Left/Root" view of my SplitView iPad app. I've figured out how to programmatically add a TableView to that view based on the example code I found in Apple's online documentation...
RootViewController.h
@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate, UITableViewDelegate, UITableViewDataSource> {
DetailViewController *detailViewController;
UITableView *tableView;
NSFetchedResultsController *fetchedResultsController;
NSManagedObjectContext *managedObjectContext;
}
RootViewController.m
- (void)loadView
{
UITableView *newTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
newTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
newTableView.delegate = self;
newTableView.dataSource = self;
[newTableView reloadData];
self.view = newTableView;
[newTableView release];
}
but there are a few things I don't understand about it and I was hoping you veterans could help clear up some confusion.
In the statement self.view = newTableView, I assume I'm setting the entire view to a single UITableView. If that's the case, then how can I add additional view objects to that view alongside the table view? For example, if I wanted to have a DatePicker view object and the TableView object instead of just the TableView object, then how would I programmatically add that?
Referencing the code above, how can I resize the table view to make room for the DatePicker view object that I'd like to add?
Thanks so much in advance for your help! I'm going to continue researching these questions right now.