How can I replace a UITableViewController with a UIViewController that contains a UITableView?
I created a new SplitView iPad project in Xcode and setup t开发者_运维知识库he 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...
- Is this the correct approach to add a DatePicker to the "Left" RootView?
- 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
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.
精彩评论