views:

330

answers:

1

I created a new SplitView iPad project in Xcode and setup the code to populate the TableView (in the RootView on the left) with data. Now I'd like to customize the RootView to contain a DatePicker view along with the TableView, but I'm unsure how to accomplish this. Since the default RootViewController is a subclass of a UITableViewController, I couldn't add a DatePicker view to it in IB (since you can't add a DatePicker to a UITableView). The only way I understand to accomplish my goal of adding a DatePicker to the "Left" RootView is to change the RootViewController from a subclass of a UITableViewController to a subclass of a UIViewController, then I'll be able to add a view to it that contains a DatePicker view and a TableView using IB. Questions...

  1. Is this the correct approach to add a DatePicker to the "Left" RootView?
  2. If so and I change the RootViewController to a subclass of a UIViewController (instead of a UITableViewController) and add to it a TableView (along with the DatePicker), how will that affect the code I currently have in place for populating my current TableView?

Thanks so much for all your help! Below is my current interface code for my RootViewController, if it'll help any.

@interface RootViewController : UITableViewController <NSFetchedResultsControllerDelegate> {

    DetailViewController *detailViewController;

    NSFetchedResultsController *fetchedResultsController;
    NSManagedObjectContext *managedObjectContext;
}

@property (nonatomic, retain) IBOutlet DetailViewController *detailViewController;    
@property (nonatomic, retain) NSFetchedResultsController *fetchedResultsController;
@property (nonatomic, retain) NSManagedObjectContext *managedObjectContext;

- (void)insertNewObject:(id)sender;

@end
+1  A: 

Yes it is annoying that you cant add elements to a subclass of UITableViewController, what i would do is, just make RootViewController a subclass of UIViewController, define a property UITableView *tableView in your root view controller and u should be fine after that, i have done this before and its pretty easy, also make sure you change the UITAbleView in your nib to a UIView and add a table view to that view if u want and tie it to the tableView property (if thats what you want you can also do this part programatically )...just keep in mind if you were changing around view sizes which causes the UITableView to resize automatically (because the UITableViewCOntroller handles that), then you will probably have to take care of that programatically.

Daniel
Thanks, Daniel! That's sounds like the best route. I assume I'm also going to have to add support for the UITableViewDelegate and UITableViewDataSource to my RootViewController in order to maintain the existing code, correct?
BeachRunnerJoe
yea, you should do that too (set the delegate and datasource to whatever u had them to before)
Daniel