I am building a dashboard for the iPad which will have 5-8 different UITableViews displayed on the single view. I have divided my iPad main view into several UIViews like “commercialProjectView”. Then I added a new UITableViewController to my storyboard and set the class to “CommercialProjectViewController”. Then in my main controller “ViewController” I added the UITableViewController to my commercialProjectView as shown below:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
CommercialProjectViewController *commercialProjectViewController = [[CommercialProjectViewController alloc] init];
[self.commercialProjectView addSubview:commercialProjectViewController.view];
}
The above does not work and throws from EXCE_ exception. What am I doing wrong?
There’s probably more detail to the exception that you’re missing somewhere. The code sample & exception have nothing to do with your setup or the title of this question.
Generally speaking, it’s not recommended to add another view controller’s view into your view hierarchy unless you’re creating a view controller container (like UITabBarController or UINavigationController).
There’s a mechanism for creating these types of containers in iOS 5 called UIViewControllerContainment. I’d watch the video on this topic from WWDC 2011 found at http://developer.apple.com/wwdc/.