I have a xib with a view which contains two views which each contain a tableview shortened in height. The root view has a segmented controller wich should toggle the views. How can I make each tableview point to it's appropriate class?
A:
One way to do it is to add two UITableViewController classes to your project from File->Add, then click on Include Xib option. This will create the two table views xib files along with. You can then init the two controllers while in your main controller's ViewDidLoad event, and assign them a frame that is equal to the left & right views you have as follows:
[firstTableController.view setFrame:rightView.frame];
[secondTableController.view setFrame:leftView.frame];
Where both rightView & leftView are UIView * objects that are hooked to your two views in IB.
You can then simply add the two table controllers to your main view controller using addSubView from the main controller:
[self.view addSubView:firstTableController.view];
[self.view addSubView:secondTableController.view];
Hope this helps.
That's genius. Thanks so much.
Oh Danny Boy
2010-08-02 18:04:22