Question

I am attempting to add a UITableViewController subclass from another storyboard into the current on as one of the tab bar view controllers.

I am using the following code which is working for other view controllers.

UIViewController *vc;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
if (storyboard)
{
  vc = [storyboard instantiateViewControllerWithIdentifier:@"ABCCustomViewControllerStoaryboardID"];
}

This gives me the following error:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key fitnessStatusView.'

The fitnessStatusView is an outlet to a subview of one of the Static cells.

If I remove the outlet connection to this subview the problem goes away.

Is it not possible to connect a view in this way? It works fine when used in the storyboard that it is created in.

Any suggestions as to what I'm doing wrong here? Thanks.

Was it helpful?

Solution 3

I figured out the problem. It was related to the fact I testing another target and the table view subclass was not included in that target.

I must admit it would have been nice if I got a class not found error.

OTHER TIPS

Try this code :

UIStoryboard *loStoryboard ;
loStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];

This code for navigate from AppDelegate Class..

// Instantiate the initial view controller object from the storyboard
UIViewController *initialViewController = [loStoryboard instantiateInitialViewController];

// Instantiate a UIWindow object and initialize it with the screen size of the iOS device
self.view = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

// Set the initial view controller to be the root view controller of the window object
[self.navigationController pushViewController:initialViewController animated:YES];

This code for navigate from Tabbar Controller..

UIViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"ABCCustomViewControllerStoaryboardID"];
[self.navigationController pushViewController:vc animated:YES];

Nope, you're not supposed to attach outlets from View Controllers to UITableViewCell subviews. Yes, I understand that the storboard allows it but it won't work in runtime as you (and I) have already found out.

I don't know why you need an outlet to a static cell subview though, because by definition, you shouldn't have to modify it because it's static.

If you really want an outlet to it, you can create a UITableViewCell subclass, assign it to the cell with the subview you want and then you can create the outlet from the subview in the storyboard to the UITableViewCell subclass. You can access the outlet in tableView:cellForRowAtIndexPath. Although that would make your table view dynamic. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top